Re: Linux application level timers?

Chris Friesen
2003-01-23T16:19:40Z

I used setitimer for a similar task. Since you can only have one timer
going at any given time, I set up a linked list of timing events, with
each event's timeout expressed as a delta from the previous event. This
way changing the time on the system has no effect on the application.
The itimer is then set for the first event in the list. When a timer
goes off, it optionally re-inserts the event into the list, starts the
next itimer, and then calls a callback function for the expired event
with an opaque data pointer as an argument.

Works really well.

Chris

--
Chris Friesen | MailStop: 043/33/F10
Nortel Networks | work: (613) 765-0557
3500 Carling Avenue | fax: (613) 765-2986
Nepean, ON K2H 8E9 Canada | email: cfriesen@nortelnetworks.com