[timers] - triggering at the same time
Jonathan Neuschäfer
j.neuschaefer at gmx.net
Sun Dec 18 20:06:20 CET 2011
On Sun, Dec 18, 2011 at 10:32:50AM -0800, Neeraj Rai wrote:
> > otoh, why do you need the strict timer ordering? maybe your
> > goal can be achieved without it?
> We have certain resources that become available at certain times- the
> times are controlled by config and subject to change.
> When users come in looking to use the resource, and the resource is not
> available, the request is queued to trigger at the specic time (cfg based)
> When the time arrives, we want to give the resourse to users in the order
> they requested.
To me it sounds like you could have one timer that fires when this
resource becomes available, and some kind of queue that tracks the users
who requested it. Some pseudo-code:
on request:
if the resource is available and the request queue is empty:
serve the user
else:
add user to the queue
on resource timeout:
while resource is available:
get a user from the list,
serve it
HTH,
Jonathan Neuschäfer
More information about the libev
mailing list