The stimer library provides functions for setting, resetting and restarting timers, and for checking if a timer has expired.
An application must "manually" check if its timers have expired; this is not done automatically.
A timer is declared as a struct
stimer
and all access to the timer is made by a pointer to the declared timer.
Data Structures | |
struct | stimer |
A timer. More... | |
Files | |
file | stimer.c |
Timer of seconds library implementation. | |
file | stimer.h |
Second timer library header file. | |
Macros | |
#define | SCLOCK_GEQ(a, b) |
Functions | |
unsigned long | stimer_elapsed (struct stimer *t) |
The time elapsed since the timer started. More... | |
int | stimer_expired (struct stimer *t) |
Check if a timer has expired. More... | |
unsigned long | stimer_remaining (struct stimer *t) |
The time until the timer expires. More... | |
void | stimer_reset (struct stimer *t) |
Reset the timer with the same interval. More... | |
void | stimer_restart (struct stimer *t) |
Restart the timer from the current point in time. More... | |
void | stimer_set (struct stimer *t, unsigned long interval) |
Set a timer. More... | |
#define SCLOCK_GEQ | ( | a, | |
b | |||
) |
Referenced by stimer_expired().
unsigned long stimer_elapsed | ( | struct stimer * | t | ) |
The time elapsed since the timer started.
This function returns the time elapsed.
t | A pointer to the timer |
References clock_seconds(), and start.
int stimer_expired | ( | struct stimer * | t | ) |
Check if a timer has expired.
This function tests if a timer has expired and returns true or false depending on its status.
t | A pointer to the timer |
References clock_seconds(), interval, SCLOCK_GEQ, and start.
Referenced by uip_ds6_defrt_periodic(), uip_ds6_neighbor_periodic(), and uip_ds6_periodic().
unsigned long stimer_remaining | ( | struct stimer * | t | ) |
The time until the timer expires.
This function returns the time until the timer expires.
t | A pointer to the timer |
References clock_seconds(), interval, and start.
Referenced by ra_input(), and uip_ds6_get_least_lifetime_neighbor().
void stimer_reset | ( | struct stimer * | t | ) |
Reset the timer with the same interval.
This function resets the timer with the same interval that was given to the stimer_set() function. The start point of the interval is the exact time that the timer last expired. Therefore, this function will cause the timer to be stable over time, unlike the stimer_restart() function.
t | A pointer to the timer. |
void stimer_restart | ( | struct stimer * | t | ) |
Restart the timer from the current point in time.
This function restarts a timer with the same interval that was given to the stimer_set() function. The timer will start at the current time.
t | A pointer to the timer. |
References clock_seconds(), and start.
void stimer_set | ( | struct stimer * | t, |
unsigned long | interval | ||
) |
Set a timer.
This function is used to set a timer for a time sometime in the future. The function stimer_expired() will evaluate to true after the timer has expired.
t | A pointer to the timer |
interval | The interval before the timer expires. |
References clock_seconds(), interval, and start.
Referenced by dao_input(), dio_input(), na_input(), ra_input(), tcpip_ipv6_output(), uip_ds6_addr_add(), uip_ds6_defrt_add(), uip_ds6_init(), uip_ds6_link_neighbor_callback(), uip_ds6_nbr_add(), uip_ds6_neighbor_periodic(), and uip_ds6_prefix_add().