cwist
Modern C web framework with libttak runtime
Loading...
Searching...
No Matches
scheduler.h
Go to the documentation of this file.
1
6#ifndef __CWIST_SCHEDULER_H__
7#define __CWIST_SCHEDULER_H__
8
10#include <stdbool.h>
11#include <stdint.h>
12#include <stddef.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
21typedef struct cwist_scheduler cwist_scheduler_t;
22
30cwist_scheduler_t *cwist_scheduler_create(size_t worker_count, size_t queue_capacity);
31
39
45
53 uint64_t delay_ms);
54
59
65typedef void (*cwist_scheduler_drop_cb)(void *arg);
66
86
87#ifdef __cplusplus
88}
89#endif
90
91#endif /* __CWIST_SCHEDULER_H__ */
Platform Agnostic Async Job Queue Interface.
void(* cwist_job_func)(void *arg)
Job function signature.
Definition cwist_io.h:22
void cwist_scheduler_destroy(cwist_scheduler_t *s)
Destroy the scheduler and stop all worker threads.
Definition scheduler.c:327
bool cwist_scheduler_submit(cwist_scheduler_t *s, cwist_job_func func, void *arg)
Submit a job to be executed as soon as a worker is available.
Definition scheduler.c:360
struct cwist_scheduler cwist_scheduler_t
Opaque background job scheduler handle.
Definition scheduler.h:21
bool cwist_scheduler_schedule(cwist_scheduler_t *s, cwist_job_func func, void *arg, uint64_t delay_ms)
Schedule a job to run after a relative delay.
Definition scheduler.c:380
size_t cwist_scheduler_pending_count(cwist_scheduler_t *s)
Number of delayed jobs currently waiting to fire.
Definition scheduler.c:412
size_t cwist_scheduler_cancel_pending(cwist_scheduler_t *s, cwist_scheduler_drop_cb drop_cb)
Cancel all delayed jobs that have not yet fired.
Definition scheduler.c:429
cwist_scheduler_t * cwist_scheduler_create(size_t worker_count, size_t queue_capacity)
Create a scheduler with a pool of background workers.
Definition scheduler.c:265
void(* cwist_scheduler_drop_cb)(void *arg)
Callback invoked for each pending job that is cancelled.
Definition scheduler.h:65