Execute a function at an interval or after a delay. More...
Data Structures | |
struct | bio_timer_t |
Handle to a timer. More... | |
Enumerations | |
enum | bio_timer_type_t { BIO_TIMER_ONESHOT , BIO_TIMER_INTERVAL } |
Types of timer. More... | |
Functions | |
bio_timer_t | bio_create_timer (bio_timer_type_t type, bio_time_t timeout_ms, bio_entrypoint_t fn, void *userdata) |
Create a new timer. | |
bool | bio_is_timer_pending (bio_timer_t timer) |
Check whether a timer is pending. | |
void | bio_reset_timer (bio_timer_t timer, bio_time_t timeout_ms) |
Reset a timer. | |
void | bio_cancel_timer (bio_timer_t timer) |
Cancel a timer. | |
Execute a function at an interval or after a delay.
enum bio_timer_type_t |
void bio_cancel_timer | ( | bio_timer_t | timer | ) |
Cancel a timer.
For a timer of type BIO_TIMER_ONESHOT, it is guaranteed that the associated function will not be invoked if the timer has not fired.
bio_timer_t bio_create_timer | ( | bio_timer_type_t | type, |
bio_time_t | timeout_ms, | ||
bio_entrypoint_t | fn, | ||
void * | userdata | ||
) |
Create a new timer.
type | The type of timer |
timeout_ms | The period or the delay for the timer in milliseconds |
fn | The function to be called |
userdata | Data passed to fn |
bool bio_is_timer_pending | ( | bio_timer_t | timer | ) |
Check whether a timer is pending.
For an uncancelled timer of type BIO_TIMER_INTERVAL, this will always return true
.
void bio_reset_timer | ( | bio_timer_t | timer, |
bio_time_t | timeout_ms | ||
) |
Reset a timer.
For a timer of type BIO_TIMER_ONESHOT, this will postpone the execution time as if bio_create_timer was just called at this point.
For a timer of type BIO_TIMER_INTERVAL, the current wait interval will be cancelled. The timer will begin a new wait interval with value timeout_ms
.
timer | The timer to reset |
timeout_ms | The new timeout |