What is the best algorithm to implement a simple timer library. The library should allow the following:
- Timers to be started
- Timers to be stopped
- Timers to be checked whether they are still running
On Timer expiry a callback function will be called.
The timer module will allow timers to have a time resolution of Ns and the module shall be given a kick every Ns to prompt the module to check for expired timers.
Many timers may be simultaneously active.
The best algorithm needs to meet the following goals
- Be Robust to timers being started / stopped while processing a timer expiry callback
- Allow timers to be started, stopped and checked quickly
- Have a small memory footprint
Regards