Correct API to implement a timer in a real-time thread