You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Marco Spinetti <m....@pisa.iol.it> on 2004/01/16 08:50:57 UTC

Apr_poll

Hi all,

because of my failure using threads in apache 1.3.x with apr (apache 
mail list tells me that using threads with apache 1.3 isn't possible), I 
decided to replace threads with apr_poll.

I don't know much about apr_poll: my purpose was to use threads to 
execute different connections simultanealy.

Is it possible using apr_poll?

Does it execute no blocking IO?


Thanks for your advice


--Marco




Re: APR - Setting Generic Timers

Posted by Ben Laurie <be...@algroup.co.uk>.
Wray Ferrell wrote:

> Having spent a few days looking at what APR has
> to offer, I noticed that there does not appear to
> be anyway to set a generic timer. The functions
> apr_thread_cond_timedwait put the thread to sleep
> while waiting for either the condition to be fullfilled
> or the timeout to occur. What I am looking for, and
> feel sure I overlooked, is the ability for a thread to
> set a timer with an expiration and a callback function.
> 
> For example, use a VOIP phone using the SIP protocol.
> The phone sends out an INVITE and then sets a timer
> with a callback function. If that timer pops the phone
> knows that no response to the initial INVITE has been
> recieved so the phone will re-transmit the INVITE.
> However this thread cannot sleep because it must still
> process data from the DSP, the user could decide to
> hangup, etc...
> 
> How would this be modeled in APR or is APR a
> purely event-driven model?

The first question to ask is: is this a facility that can be provided on 
all (or at least most) systems we support? Because if it isn't, it isn't 
a candidate for APR.

If it is, then we would certainly consider adding it. Don't think we do 
it right now, though.

OTOH, the thing I'm trying to resolve (slowly) is how to do 
cross-platform select() or poll() that works on more than just sockets 
(in particular, pipes, too). With that, you can get what you want using 
the time-out argument. Which is probably better and simpler anyway.

Cheers,

Ben.

-- 
http://www.apache-ssl.org/ben.html       http://www.thebunker.net/

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff

APR - Setting Generic Timers

Posted by Wray Ferrell <wf...@cisco.com>.
Having spent a few days looking at what APR has
to offer, I noticed that there does not appear to
be anyway to set a generic timer. The functions
apr_thread_cond_timedwait put the thread to sleep
while waiting for either the condition to be fullfilled
or the timeout to occur. What I am looking for, and
feel sure I overlooked, is the ability for a thread to
set a timer with an expiration and a callback function.

For example, use a VOIP phone using the SIP protocol.
The phone sends out an INVITE and then sets a timer
with a callback function. If that timer pops the phone
knows that no response to the initial INVITE has been
recieved so the phone will re-transmit the INVITE.
However this thread cannot sleep because it must still
process data from the DSP, the user could decide to
hangup, etc...

How would this be modeled in APR or is APR a
purely event-driven model?

Thanks, Wray


Re: Apr_poll

Posted by Wray Ferrell <wf...@cisco.com>.
>
> In this way is very hard to use apr for a new user. 


I agree that the documentation in the 0.9.4 release leaves quite
a bit to be desired. I too have just picked up APR to see if
it can be used in a project I am working on. However on
the net I found a much better set of documentation than what
is linked to on the APR homepage.

http://holsman.net/group__apr__poll.html

Wray


Re: Apr_poll

Posted by Marco Spinetti <m....@pisa.iol.it>.
I tried to read the examples about apr_poll in test directory of apr but 
it's very hard.

Is there any docs about apr_poll? No docs is in the web page 
http://apr.apache.org and no docs about apr is with the software.

In this way is very hard to use apr for a new user.

For example there is no dcs about all these define

#define APR_POLLIN 0x001 00087
#define APR_POLLPRI 0x002 00088
#define APR_POLLOUT 0x004 00089
#define APR_POLLERR 0x010 00090
#define APR_POLLHUP 0x020 00091
#define APR_POLLNVAL 0x040

What are the differences ?

Can someone tell me how to use apr_poll or where I can find more docs?


Thanks very much



--Marco


 
Bill Stoddard wrote:

> Marco Spinetti wrote:
>
>> Hi all,
>>
>> because of my failure using threads in apache 1.3.x with apr (apache 
>> mail list tells me that using threads with apache 1.3 isn't 
>> possible), I decided to replace threads with apr_poll.
>>
>> I don't know much about apr_poll: my purpose was to use threads to 
>> execute different connections simultanealy.
>>
>> Is it possible using apr_poll?
>>
>> Does it execute no blocking IO?
>>
>>
>> Thanks for your advice
>>
>>
>> --Marco
>
>
> Apache 1.3 on Unix uses uses blocking network i/o and signals for 
> doing timeouts. It would be possible to do non-blocking network i/o 
> but then you'd have to deal with all the state information (i/o 
> buffers, et. al.) that resides on the call stack.
>
> Bill
>



Re: Apr_poll

Posted by Bill Stoddard <bi...@wstoddard.com>.
Marco Spinetti wrote:

> Hi all,
> 
> because of my failure using threads in apache 1.3.x with apr (apache 
> mail list tells me that using threads with apache 1.3 isn't possible), I 
> decided to replace threads with apr_poll.
> 
> I don't know much about apr_poll: my purpose was to use threads to 
> execute different connections simultanealy.
> 
> Is it possible using apr_poll?
> 
> Does it execute no blocking IO?
> 
> 
> Thanks for your advice
> 
> 
> --Marco

Apache 1.3 on Unix uses uses blocking network i/o and signals for doing timeouts. It would be possible to do 
non-blocking network i/o but then you'd have to deal with all the state information (i/o buffers, et. al.) 
that resides on the call stack.

Bill