GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Timers and timer queue implementation. More...
Go to the source code of this file.
Data Structures | |
struct | gp_timer |
A timer. More... | |
Macros | |
#define | GP_TIMER_STOP UINT32_MAX |
Return this value from the callback to stop a timer. | |
Functions | |
static int | gp_timer_running (gp_timer *timer) |
Returns if timer is running. | |
void | gp_timer_queue_dump (gp_timer *queue) |
Prints the structrue of binary heap into stdout, only for debugging. | |
void | gp_timer_queue_ins (gp_timer **queue, uint64_t now, gp_timer *timer) |
Inserts timer into the timer priority queue. | |
void | gp_timer_queue_rem (gp_timer **queue, gp_timer *timer) |
Removes timer from timer queue. | |
int | gp_timer_queue_process (gp_timer **queue, uint64_t now) |
Processes queue, all timers with expires <= now are processed. | |
static unsigned int | gp_timer_queue_size (gp_timer *queue) |
Returns size of the queue, i.e. number of timers. | |
Timers and timer queue implementation.
Definition in file gp_timer.h.
void gp_timer_queue_dump | ( | gp_timer * | queue | ) |
Prints the structrue of binary heap into stdout, only for debugging.
queue | A timer queue. |
Inserts timer into the timer priority queue.
If timer is already running nothing is done. In order to reschedulle a timer it has to be removed from the queue first.
It's safe to call insert from the timer callback.
If timer was removed then inserted from the timer callback the timer is reschedulled at now + timer->expired time and the return value from the callback is discarded.
queue | A timer queue. |
now | A timestamp, usually obtained by calling gp_time_stamp(). |
timer | A timer to insert. |
int gp_timer_queue_process | ( | gp_timer ** | queue, |
uint64_t | now | ||
) |
Processes queue, all timers with expires <= now are processed.
It's possible to reschedulle a timer with expires set to 0, which will process the timer on the next process call.
queue | A timer queue. |
now | A timestamp, usually obtained by calling gp_time_stamp(). |
Removes timer from timer queue.
It's safe to call remove from the timer callback.
If called from the timer callback the timer is stopped and the return value from the callback is discarded.
queue | A timer queue. |
timer | A timer to insert. |
|
inlinestatic |
Returns size of the queue, i.e. number of timers.
queue | A timer queue. |
Definition at line 139 of file gp_timer.h.
Referenced by gp_backend_timers_queued().
|
inlinestatic |
Returns if timer is running.
A timer is running if it's inserted into a timer queue.
timer | A timer. |
Definition at line 78 of file gp_timer.h.
References gp_timer::running.