Callback scheduling API.
More...
|
void | discord_timers_init (struct discord_timers *timers, struct io_poller *io) |
| Prepare timers for usage. More...
|
|
void | discord_timers_cleanup (struct discord *client, struct discord_timers *timers) |
| Cleanup timers and call cancel any running ones. More...
|
|
int64_t | discord_timers_get_next_trigger (struct discord_timers *const timers[], size_t n, int64_t now, int64_t max_time) |
| Get earliest trigger time from a group of timers. More...
|
|
void | discord_timers_run (struct discord *client, struct discord_timers *timers) |
| Run all timers that are due. More...
|
|
unsigned | _discord_timer_ctl (struct discord *client, struct discord_timers *timers, struct discord_timer *timer) |
| Modifies or creates a timer. More...
|
|
unsigned | discord_internal_timer_ctl (struct discord *client, struct discord_timer *timer) |
| Modifies or creates a timer. More...
|
|
unsigned | discord_internal_timer (struct discord *client, discord_ev_timer on_tick_cb, discord_ev_timer on_status_changed_cb, void *data, int64_t delay) |
| Creates a one shot timer that automatically deletes itself upon completion. More...
|
|
Callback scheduling API.
◆ discord_timers_init()
void discord_timers_init |
( |
struct discord_timers * |
timers, |
|
|
struct io_poller * |
io |
|
) |
| |
Prepare timers for usage.
- Parameters
-
◆ discord_timers_cleanup()
Cleanup timers and call cancel any running ones.
- Parameters
-
◆ discord_timers_get_next_trigger()
int64_t discord_timers_get_next_trigger |
( |
struct discord_timers *const |
timers[], |
|
|
size_t |
n, |
|
|
int64_t |
now, |
|
|
int64_t |
max_time |
|
) |
| |
Get earliest trigger time from a group of timers.
- Parameters
-
timers | array of timers |
n | number of timers in array |
now | current time |
max_time | max time to allowed |
- Returns
- time in microseconds until next timer, or max
◆ discord_timers_run()
Run all timers that are due.
- Parameters
-
◆ _discord_timer_ctl()
Modifies or creates a timer.
- Parameters
-
client | the client created with discord_init() |
timers | the timer group to perform this operation on |
timer | the timer that should be modified |
- Returns
- the id of the timer
◆ discord_internal_timer_ctl()
Modifies or creates a timer.
- Parameters
-
client | the client created with discord_init() |
timer | the timer that should be modified |
- Returns
- the id of the timer
◆ discord_internal_timer()
Creates a one shot timer that automatically deletes itself upon completion.
- Parameters
-
client | the client created with discord_init() |
on_tick_cb | (nullable) the callback that should be called when timer triggers |
on_status_changed_cb | (nullable) the callback for status updates timer->flags will have: DISCORD_TIMER_CANCELED, and DISCORD_TIMER_DELETE |
data | user data |
delay | delay before timer should start in milliseconds |
- Returns
- the id of the timer