You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Wray Ferrell <wf...@cisco.com> on 2004/01/20 17:23:02 UTC

APR - Setting Generic Timers

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 - 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