32 static void ev_thrd_loop_exec_on_task_init(
ev_exec_t *exec);
33 static void ev_thrd_loop_exec_on_task_fini(
ev_exec_t *exec);
34 static int ev_thrd_loop_exec_dispatch(
ev_exec_t *exec,
struct ev_task *task);
36 static size_t ev_thrd_loop_exec_abort(
ev_exec_t *exec,
struct ev_task *task);
40 static const struct ev_exec_vtbl ev_thrd_loop_exec_vtbl = {
41 &ev_thrd_loop_exec_on_task_init,
42 &ev_thrd_loop_exec_on_task_fini,
43 &ev_thrd_loop_exec_dispatch,
44 &ev_thrd_loop_exec_defer,
45 &ev_thrd_loop_exec_defer,
46 &ev_thrd_loop_exec_abort,
47 &ev_thrd_loop_exec_run
71 static void ev_thrd_loop_on_task_init(
struct ev_thrd_loop *loop);
72 static void ev_thrd_loop_on_task_fini(
struct ev_thrd_loop *loop);
77 static ev_exec_t ev_thrd_loop_exec = &ev_thrd_loop_exec_vtbl;
79 return &ev_thrd_loop_exec;
162 ev_thrd_loop_on_task_init(loop);
164 ev_thrd_loop_exec_run(exec, task);
165 ev_thrd_loop_on_task_fini(loop);
181 assert(task->
exec == exec);
184 ev_thrd_loop_on_task_init(loop);
199 ev_thrd_loop_on_task_fini(loop);
203 ev_thrd_loop_on_task_fini(loop);
217 assert(task->
exec == exec);
This header file is part of the event library; it contains the abstract task executor interface.
void ev_exec_run(ev_exec_t *exec, struct ev_task *task)
Invokes the task function in *task as if the task is being executed by *exec.
#define _Thread_local
An object whose identifier is declared with the storage-class specifier _Thread_local has thread stor...
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
void sllist_init(struct sllist *list)
Initializes a singly-linked list.
struct slnode * sllist_remove(struct sllist *list, struct slnode *node)
Removes a node from a singly-linked list.
void sllist_push_back(struct sllist *list, struct slnode *node)
Pushes a node to the back of a singly-linked list.
struct slnode * sllist_pop_front(struct sllist *list)
Pops a node from the front of a singly-linked list.
This is the internal header file of the event library.
This header file is part of the C11 and POSIX compatibility library; it includes <stdint....
ev_task_func_t * func
The function to be invoked when the task is run.
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
A thread-local event loop.
int stopped
A flag specifying whether the event loop is stopped.
size_t ntasks
The number of pending tasks.
int running
A flag specifying whether ev_exec_run() is running on this thread.
struct sllist queue
The queue of pending tasks.
This header file is part of the event library; it contains the task declarations.
struct ev_task * ev_task_from_node(struct slnode *node)
Converts a pointer to a node in a queue to the address of the task containing the node.
size_t ev_thrd_loop_run(void)
If the thread-local event loop is not stopped, run all available tasks.
void ev_thrd_loop_stop(void)
Stops the thread-local event loop.
ev_exec_t * ev_thrd_loop_get_exec(void)
Returns a pointer to the executor corresponding to the thread-local event loop.
static struct ev_thrd_loop * ev_thrd_loop(void)
Returns a pointer to the thread-local event loop.
size_t ev_thrd_loop_run_one(void)
If the thread-local event loop is not stopped, executes the first task submitted to it,...
void ev_thrd_loop_restart(void)
Restarts a thread-local event loop.
int ev_thrd_loop_stopped(void)
Returns 1 if the thread-local event loop is stopped, and 0 if not.
This header file is part of the event library; it contains the thread-local event loop declarations.