More c99 bool declarations and a couple comments
This commit is contained in:
parent
b7df81aecc
commit
ea6dea4f37
@ -169,7 +169,10 @@ timer_free_all(void)
|
|||||||
persistent_timers = NULL;
|
persistent_timers = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
/*
|
||||||
|
* Checks whether a timer has expired
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
timer_has_expired(Any_Type a)
|
timer_has_expired(Any_Type a)
|
||||||
{
|
{
|
||||||
struct Timer *t = a.vp;
|
struct Timer *t = a.vp;
|
||||||
@ -181,13 +184,14 @@ timer_has_expired(Any_Type a)
|
|||||||
if (t->time_started + t->timeout_delay < timer_now()) {
|
if (t->time_started + t->timeout_delay < timer_now()) {
|
||||||
t->has_expired = true;
|
t->has_expired = true;
|
||||||
(*t->timeout_callback) (t, t->timer_subject);
|
(*t->timeout_callback) (t, t->timer_subject);
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
} else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
timer_deactivate(Any_Type a)
|
timer_deactivate(Any_Type a)
|
||||||
{
|
{
|
||||||
struct Timer *t = a.vp;
|
struct Timer *t = a.vp;
|
||||||
@ -212,6 +216,12 @@ timer_tick(void)
|
|||||||
list_remove_if_true(active_timers, &timer_deactivate);
|
list_remove_if_true(active_timers, &timer_deactivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Schedules a timer into the active_timer list. Usually the timer is
|
||||||
|
* requisitioned from the passive_timer list to avoid making extra calls
|
||||||
|
* to malloc, but will allocate memory for a new counter if there are no
|
||||||
|
* inactive timers available
|
||||||
|
*/
|
||||||
struct Timer *
|
struct Timer *
|
||||||
timer_schedule(void (*timeout) (struct Timer * t, Any_Type arg),
|
timer_schedule(void (*timeout) (struct Timer * t, Any_Type arg),
|
||||||
Any_Type subject, Time delay)
|
Any_Type subject, Time delay)
|
||||||
|
Loading…
Reference in New Issue
Block a user