KEEL 1.0.0
Minimal C11 HTTP client/server library built on epoll/kqueue/io_uring/poll
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1#ifndef KEEL_TIMER_H
2#define KEEL_TIMER_H
3
4#include <keel/event_ctx.h>
5#include <stdint.h>
6
11typedef void (*KlTimerFn)(void *user_data);
12
17 uint64_t deadline_ms;
19 void *user_data;
20 int64_t id;
21};
22
38int64_t kl_timer_add(KlEventCtx *ctx, uint64_t delay_ms,
39 KlTimerFn cb, void *user_data);
40
51int kl_timer_cancel(KlEventCtx *ctx, int64_t timer_id);
52
64int kl_timer_next_timeout(KlEventCtx *ctx, int max_ms);
65
76
77#endif
Composable event loop context.
Definition event_ctx.h:42
Timer heap entry (stored in KlEventCtx.timers array).
Definition timer.h:16
int64_t id
Definition timer.h:20
uint64_t deadline_ms
Definition timer.h:17
void * user_data
Definition timer.h:19
KlTimerFn cb
Definition timer.h:18
int64_t kl_timer_add(KlEventCtx *ctx, uint64_t delay_ms, KlTimerFn cb, void *user_data)
Schedule a one-shot timer.
int kl_timer_fire(KlEventCtx *ctx)
Fire all expired timers.
int kl_timer_cancel(KlEventCtx *ctx, int64_t timer_id)
Cancel a pending timer.
void(* KlTimerFn)(void *user_data)
Timer callback function.
Definition timer.h:11
int kl_timer_next_timeout(KlEventCtx *ctx, int max_ms)
Compute the timeout for the next kl_event_wait call.