Name uc_timers_XXX consistently
This commit is contained in:
+9
-9
@@ -26,9 +26,9 @@ static int timers_cmp(const void *a_, const void *b_)
|
||||
return 0; //silence compiler
|
||||
}
|
||||
|
||||
static void uc_timer_real_add(struct UCTimers *timers, struct UCTimer *timer)
|
||||
static void uc_timers_real_add(struct UCTimers *timers, struct UCTimer *timer)
|
||||
{
|
||||
uc_timer_remove(timers, timer); //re schedule it if it's already running
|
||||
uc_timers_remove(timers, timer); //re schedule it if it's already running
|
||||
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.
|
||||
@@ -49,7 +49,7 @@ void uc_timers_init_ex(struct UCTimers *t, struct UCoreClock *uclock)
|
||||
TAILQ_INIT(&t->ready_list);
|
||||
}
|
||||
|
||||
void uc_timer_add(struct UCTimers *timers, struct UCTimer *timer, int sec, int usec)
|
||||
void uc_timers_add(struct UCTimers *timers, struct UCTimer *timer, int sec, int usec)
|
||||
{
|
||||
struct timeval now;
|
||||
struct timeval tmp;
|
||||
@@ -63,10 +63,10 @@ void uc_timer_add(struct UCTimers *timers, struct UCTimer *timer, int sec, int u
|
||||
|
||||
timers->uclock->now(timers->uclock, &now);
|
||||
timeradd(&now, &tmp, &timer->timeout);
|
||||
uc_timer_real_add(timers, timer);
|
||||
uc_timers_real_add(timers, timer);
|
||||
}
|
||||
|
||||
void uc_timer_remove(struct UCTimers *timers, struct UCTimer *timer)
|
||||
void uc_timers_remove(struct UCTimers *timers, struct UCTimer *timer)
|
||||
{
|
||||
if (timer->state == UC_TIMER_INACTIVE) { //already removed , or never added.
|
||||
//debugging bandaid
|
||||
@@ -97,7 +97,7 @@ int uc_timers_first(const struct UCTimers *timers, struct timeval *first)
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t uc_timer_count(const struct UCTimers *timers)
|
||||
size_t uc_timers_count(const struct UCTimers *timers)
|
||||
{
|
||||
struct RBNode *n;
|
||||
size_t count = 0;
|
||||
@@ -134,7 +134,7 @@ int uc_timers_run(struct UCTimers *timers)
|
||||
//Note, timercmp does not work for >=
|
||||
if (!timercmp(&now, &t->timeout, <)) {
|
||||
TAILQ_INSERT_TAIL(&timers->ready_list, t, ready_entry);
|
||||
t->state = UC_TIMER_PENDING; //so uc_timer_remove knows
|
||||
t->state = UC_TIMER_PENDING; //so uc_timers_remove knows
|
||||
//it have to remove it from the ready_list
|
||||
} else {
|
||||
break;
|
||||
@@ -147,12 +147,12 @@ int uc_timers_run(struct UCTimers *timers)
|
||||
* Need to always pick the first item in the tail queue
|
||||
* since a timer callback could remove/free a timer
|
||||
* we had in the list.
|
||||
* uc_timer_remove will unlink the timer from this list.
|
||||
* uc_timers_remove will unlink the timer from this list.
|
||||
*/
|
||||
while (!TAILQ_EMPTY(&timers->ready_list)) {
|
||||
struct UCTimer *t = TAILQ_FIRST(&timers->ready_list);
|
||||
|
||||
uc_timer_remove(timers, t);
|
||||
uc_timers_remove(timers, t);
|
||||
assert(t->callback != NULL);
|
||||
t->callback(timers, t); //fire
|
||||
// callback might have free'd its timer.
|
||||
|
||||
Reference in New Issue
Block a user