Convert UCTimers to use UCoreClock

This commit is contained in:
Nils O. Selåsdal
2013-03-02 21:16:22 +01:00
parent 42269a8a91
commit b0e9988aa5
4 changed files with 25 additions and 12 deletions
+9 -1
View File
@@ -9,6 +9,7 @@
struct UCTimer;
struct UCTimers;
struct UCoreClock;
//internal timer states
enum {
@@ -62,6 +63,7 @@ struct UCTimer {
/** Timer engine. Must be initialized onnce.*/
struct UCTimers {
RBTree timer_tree;
struct UCoreClock *uclock;
size_t seq; //used to generate unique timers
TAILQ_HEAD(, UCTimer) ready_list; //pending timers to be fired while inside uc_timers_run
};
@@ -73,6 +75,12 @@ struct UCTimers {
*/
void uc_timers_init(struct UCTimers *t);
/** Initialize a timer engine for use, with a user supplied clock.
*
* @param t UCTimers struct to initialize
*/
void uc_timers_init_ex(struct UCTimers *t, struct UCoreClock *uclock);
/** Add a (one-shot) timer to the timer engine.
* User fills in the callback and any cookie members of the UCTimer. The callback
* will be called when the timer expires, and the timer is removed from the engine
@@ -127,7 +135,7 @@ int uc_timer_running(const struct UCTimer *timer);
* @return the number of timers fired, or negative if an error occured(presently no errors
* are possible and the return value is always >= 0
**/
int uc_timers_run(struct UCTimers *timers, const struct timeval *now);
int uc_timers_run(struct UCTimers *timers);
//uc_timers_destroy(struct UCTimers *timers) is currently missing..