KallistiOS git master
Independent SDK for the Sega Dreamcast
|
One-shot timer support. More...
#include <sys/cdefs.h>
Go to the source code of this file.
Typedefs | |
typedef struct oneshot_timer | oneshot_timer_t |
Functions | |
oneshot_timer_t * | oneshot_timer_create (void(*cb)(void *), void *data, unsigned int timeout_ms) |
Create a new one-shot timer. | |
void | oneshot_timer_destroy (oneshot_timer_t *timer) |
Stop and destroy a one-shot timer. | |
void | oneshot_timer_setup (oneshot_timer_t *timer, void(*cb)(void *), void *data, unsigned int timeout_ms) |
Re-configure a one-shot timer. | |
void | oneshot_timer_start (oneshot_timer_t *timer) |
Start a one-shot timer. | |
void | oneshot_timer_stop (oneshot_timer_t *timer) |
Stop a one-shot timer. | |
static void | oneshot_timer_reset (oneshot_timer_t *timer) |
Reset a one-shot timer. | |
One-shot timer support.
This file contains the one-shot timer API. A one-shot timer is a timer that will trigger an action (through a pre-registered callback) after a timeout expires.
typedef struct oneshot_timer oneshot_timer_t |
oneshot_timer_t * oneshot_timer_create | ( | void(* | cb )(void *), |
void * | data, | ||
unsigned int | timeout_ms ) |
Create a new one-shot timer.
This function will create a one-shot timer using the specified callback, programmed to expire after the given timeout. The timer will be stopped by default and still need to be started using oneshot_timer_start().
cb | The function to call in case the one-shot timer expires. |
data | A parameter to pass to the function called. |
timeout_ms | The timeout value for the one-shot timer, in milliseconds. |
void oneshot_timer_destroy | ( | oneshot_timer_t * | timer | ) |
Stop and destroy a one-shot timer.
This function will stop the one-shot timer and free its memory.
timer | A pointer to the one-shot timer. |
|
inlinestatic |
Reset a one-shot timer.
A convenience function to reset the one-shot timer by stopping it then starting it again.
timer | A pointer to the one-shot timer. |
void oneshot_timer_setup | ( | oneshot_timer_t * | timer, |
void(* | cb )(void *), | ||
void * | data, | ||
unsigned int | timeout_ms ) |
Re-configure a one-shot timer.
This function can be used to change the registered callback or the timeout. Using it on a running timer is unsupported.
timer | A pointer to the one-shot timer. |
cb | The function to call in case the one-shot timer expires. |
data | A parameter to pass to the function called. |
timeout_ms | The timeout value for the one-shot timer, in milliseconds. |
void oneshot_timer_start | ( | oneshot_timer_t * | timer | ) |
Start a one-shot timer.
This function will start the one-shot timer. If not stopped until the timeout value expires, the one-shot timer will call the registered callback function.
timer | A pointer to the one-shot timer. |
Referenced by oneshot_timer_t::oneshot_timer_reset().
void oneshot_timer_stop | ( | oneshot_timer_t * | timer | ) |
Stop a one-shot timer.
This function will stop the one-shot timer. If it already expired, this function does nothing. If it did not expire yet, the one-shot timer is stopped and the registered callback won't be called.
timer | A pointer to the one-shot timer. |
Referenced by oneshot_timer_t::oneshot_timer_reset().