-
Notifications
You must be signed in to change notification settings - Fork 4
/
iwn_scheduler.h
31 lines (22 loc) · 1.09 KB
/
iwn_scheduler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once
/// Excutes delayed tasks after specified timeout.
#include "iwn_poller.h"
#include <iowow/iwtp.h>
IW_EXTERN_C_START;
/// Task execute callback.
typedef void (*iwn_scheduler_task_f)(void *arg);
/// Delayed task spe.
struct iwn_scheduler_spec {
iwn_scheduler_task_f task_fn; ///< Task execute callback. Either `task_fn` or `on_dispose` must be specified.
void (*on_cancel)(void*); ///< Optional on_cancel handler.
/// Called when pending task execution will be cancelled for
/// some reason. Eg: poller shutdown.
void (*on_dispose)(void*); ///< Optional dispose handler. Called when task is removed from event poller.
void *user_data; ///< User data passed to `task_fn()` function.
struct iwn_poller *poller; ///< Poller.
uint32_t timeout_ms; ///< Task timeout in milliseconds.
};
/// Submits delayed task for execution.
IW_EXPORT iwrc iwn_schedule(const struct iwn_scheduler_spec *spec);
IW_EXPORT iwrc iwn_schedule2(const struct iwn_scheduler_spec *spec, int *out_fd);
IW_EXTERN_C_END;