Changeset View
Changeset View
Standalone View
Standalone View
head/sys/sys/taskqueue.h
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
void taskqueue_block(struct taskqueue *queue); | void taskqueue_block(struct taskqueue *queue); | ||||
void taskqueue_unblock(struct taskqueue *queue); | void taskqueue_unblock(struct taskqueue *queue); | ||||
int taskqueue_member(struct taskqueue *queue, struct thread *td); | int taskqueue_member(struct taskqueue *queue, struct thread *td); | ||||
void taskqueue_set_callback(struct taskqueue *queue, | void taskqueue_set_callback(struct taskqueue *queue, | ||||
enum taskqueue_callback_type cb_type, | enum taskqueue_callback_type cb_type, | ||||
taskqueue_callback_fn callback, void *context); | taskqueue_callback_fn callback, void *context); | ||||
#define TASK_INITIALIZER(priority, func, context) \ | #define TASK_INITIALIZER(priority, func, context) \ | ||||
{ .ta_pending = 0, \ | { .ta_priority = (priority), \ | ||||
.ta_priority = (priority), \ | |||||
.ta_func = (func), \ | .ta_func = (func), \ | ||||
.ta_context = (context) } | .ta_context = (context) } | ||||
/* | /* | ||||
* Functions for dedicated thread taskqueues | * Functions for dedicated thread taskqueues | ||||
*/ | */ | ||||
void taskqueue_thread_loop(void *arg); | void taskqueue_thread_loop(void *arg); | ||||
void taskqueue_thread_enqueue(void *context); | void taskqueue_thread_enqueue(void *context); | ||||
/* | /* | ||||
* Initialise a task structure. | * Initialise a task structure. | ||||
*/ | */ | ||||
#define TASK_INIT(task, priority, func, context) do { \ | #define TASK_INIT_FLAGS(task, priority, func, context, flags) do { \ | ||||
MPASS((priority) >= 0 && (priority) <= 255); \ | |||||
(task)->ta_pending = 0; \ | (task)->ta_pending = 0; \ | ||||
(task)->ta_priority = (priority); \ | (task)->ta_priority = (priority); \ | ||||
(task)->ta_flags = (flags); \ | |||||
(task)->ta_func = (func); \ | (task)->ta_func = (func); \ | ||||
(task)->ta_context = (context); \ | (task)->ta_context = (context); \ | ||||
} while (0) | } while (0) | ||||
#define TASK_INIT(t, p, f, c) TASK_INIT_FLAGS(t, p, f, c, 0) | |||||
void _timeout_task_init(struct taskqueue *queue, | void _timeout_task_init(struct taskqueue *queue, | ||||
struct timeout_task *timeout_task, int priority, task_fn_t func, | struct timeout_task *timeout_task, int priority, task_fn_t func, | ||||
void *context); | void *context); | ||||
#define TIMEOUT_TASK_INIT(queue, timeout_task, priority, func, context) \ | #define TIMEOUT_TASK_INIT(queue, timeout_task, priority, func, context) do { \ | ||||
_timeout_task_init(queue, timeout_task, priority, func, context); | _Static_assert((priority) >= 0 && (priority) <= 255, \ | ||||
"struct task priority is 8 bit in size"); \ | |||||
_timeout_task_init(queue, timeout_task, priority, func, context); \ | |||||
} while (0) | |||||
/* | /* | ||||
* Declare a reference to a taskqueue. | * Declare a reference to a taskqueue. | ||||
*/ | */ | ||||
#define TASKQUEUE_DECLARE(name) \ | #define TASKQUEUE_DECLARE(name) \ | ||||
extern struct taskqueue *taskqueue_##name | extern struct taskqueue *taskqueue_##name | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |