Rename RB timers to timer_tree
This commit is contained in:
+7
-7
@@ -31,13 +31,13 @@ static void uc_timer_real_add(struct UCTimers *timers, struct UCTimer *timer)
|
||||
timer->state = UC_TIMER_ACTIVE;
|
||||
timer->seq = timers->seq++;
|
||||
timer->rb_node.data = timer; //point the data in a RBNode back to the timer that contains it.
|
||||
uc_rb_insert(&timers->timers, &timer->rb_node);
|
||||
uc_rb_insert(&timers->timer_tree, &timer->rb_node);
|
||||
}
|
||||
|
||||
void uc_timers_init(struct UCTimers *t)
|
||||
{
|
||||
t->timers.node = NULL;
|
||||
t->timers.compare = timers_cmp;
|
||||
t->timer_tree.node = NULL;
|
||||
t->timer_tree.compare = timers_cmp;
|
||||
t->seq = 0;
|
||||
TAILQ_INIT(&t->ready_list);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ void uc_timer_remove(struct UCTimers *timers, struct UCTimer *timer)
|
||||
return;
|
||||
}
|
||||
|
||||
uc_rb_remove(&timers->timers, &timer->rb_node); //remove it, safe for the
|
||||
uc_rb_remove(&timers->timer_tree, &timer->rb_node); //remove it, safe for the
|
||||
//callback to re_add it
|
||||
if (timer->state == UC_TIMER_PENDING) {
|
||||
//timer is pending for callback, remove it from the list
|
||||
@@ -80,7 +80,7 @@ void uc_timer_remove(struct UCTimers *timers, struct UCTimer *timer)
|
||||
|
||||
int uc_timers_first(const struct UCTimers *timers, struct timeval *first)
|
||||
{
|
||||
const RBNode *n = uc_rb_first(&timers->timers);
|
||||
const RBNode *n = uc_rb_first(&timers->timer_tree);
|
||||
if (n) {
|
||||
struct UCTimer *timer = n->data;
|
||||
*first = timer->timeout;
|
||||
@@ -95,7 +95,7 @@ size_t uc_timer_count(const struct UCTimers *timers)
|
||||
struct RBNode *n;
|
||||
size_t count = 0;
|
||||
|
||||
for (n = uc_rb_first(&timers->timers); n ; n = uc_rb_next(n)) {
|
||||
for (n = uc_rb_first(&timers->timer_tree); n ; n = uc_rb_next(n)) {
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ int uc_timers_run(struct UCTimers *timers, const struct timeval *now)
|
||||
*/
|
||||
assert(TAILQ_EMPTY(&timers->ready_list)); //somethings serious wrong if it isn't already empty
|
||||
TAILQ_INIT(&timers->ready_list);
|
||||
for (node = uc_rb_first(&timers->timers); node ; node = uc_rb_next(node)) {
|
||||
for (node = uc_rb_first(&timers->timer_tree); node ; node = uc_rb_next(node)) {
|
||||
struct UCTimer *t = node->data;
|
||||
//Note, timercmp does not work for >=
|
||||
if (!timercmp(now, &t->timeout, <)) {
|
||||
|
||||
Reference in New Issue
Block a user