I need to add timers support in an application based on I/O Completion Ports (IOCP). I would like to avoid the use of a specific thread to manage timers.
On Linux, you can create a timer that delivers expiration notifications via a file descriptor (see timerfd.h man), so it's great to use it for example with epoll if your application is based on epoll.
On Windows, you can use "waitable timers" with an asynchronous procedure call (ACP) (see http://msdn.microsoft.com/en-us/library/ms686898(v=VS.85).aspx)
If you are interested, kqueue (BSD, Mac OS) supports timers by default (see EVFILT_TIMER).
With I/O Completion Ports, we have to use objets that support overlapped I/O. So, is there such a timer for IOCP ?
Best regards,
Cédrics
As far as I know there are no timers that generate a IOCP completion when they expire.
You could try the Windows timer queue; CreateTimerQueueTimer.
I ended up writing my own timer queue which does use an extra thread to run the timers, so it's probably no good for you: See here for a series of articles where I implement the queue with TDD and full unit tests. I'm in the process of implementing a higher performance TimerWheel with the same interface, but again that will use an external thread to manage the timers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With