38 static void ev_std_exec_on_task_init(
ev_exec_t *exec);
39 static void ev_std_exec_on_task_fini(
ev_exec_t *exec);
48 &ev_std_exec_on_task_init,
49 &ev_std_exec_on_task_fini,
50 &ev_std_exec_dispatch,
81 ev_std_exec_alloc(
void)
89 return exec ? &exec->exec_vptr : NULL;
93 ev_std_exec_free(
void *ptr)
96 free(ev_std_exec_from_exec(ptr));
100 ev_std_exec_init(
ev_exec_t *exec_, ev_std_exec_impl_t *impl)
102 struct ev_std_exec *exec = ev_std_exec_from_exec(exec_);
105 exec->exec_vptr = &ev_std_exec_vtbl;
119 ev_std_exec_create(ev_std_exec_impl_t *impl)
129 ev_exec_t *tmp = ev_std_exec_init(exec, impl);
139 ev_std_exec_free((
void *)exec);
149 ev_std_exec_fini(exec);
150 ev_std_exec_free((
void *)exec);
155 ev_std_exec_on_task_init(
ev_exec_t *exec_)
157 struct ev_std_exec *exec = ev_std_exec_from_exec(exec_);
159 assert((*exec->impl)->on_task_init);
161 (*exec->impl)->on_task_init(exec->impl);
165 ev_std_exec_on_task_fini(
ev_exec_t *exec_)
167 struct ev_std_exec *exec = ev_std_exec_from_exec(exec_);
169 assert((*exec->impl)->on_task_fini);
171 (*exec->impl)->on_task_fini(exec->impl);
178 assert(!task->
exec || task->
exec == exec);
182 ev_std_exec_post(exec, task);
198 struct ev_std_exec *exec = ev_std_exec_from_exec(exec_);
200 assert((*exec->impl)->post);
202 assert(!task->
exec || task->
exec == exec_);
207 (*exec->impl)->post(exec->impl, task);
215 assert(!task->
exec || task->
exec == exec);
219 ev_std_exec_post(exec, task);
226 ev_std_exec_on_task_init(exec);
227 assert((*pnode)->queue);
228 assert((*pnode)->queue->queue);
235 struct ev_std_exec *exec = ev_std_exec_from_exec(exec_);
237 assert((*exec->impl)->abort);
244 assert((*pnode)->queue);
245 struct sllist *queue = (*pnode)->queue->queue;
249 ev_std_exec_on_task_fini(exec_);
250 nnode += nnode < SIZE_MAX;
253 ev_std_exec_on_task_fini(exec_);
259 nimpl = (*exec->impl)->abort(exec->impl, task);
261 return nimpl < SIZE_MAX - nnode ? nnode + nimpl : SIZE_MAX;
267 struct ev_std_exec *exec = ev_std_exec_from_exec(exec_);
269 assert((*exec->impl)->post);
271 assert(!task->
exec || task->
exec == exec_);
282 struct ev_exec_node exec_node = { NULL, exec_, &queue_node };
286 queue_node.next = (*pnode)->queue;
287 (*pnode)->queue = &queue_node;
289 exec_node.next = *plist;
295 pnode = ev_exec_find(exec_, plist);
297 assert((*pnode)->queue == &queue_node);
298 if ((*pnode)->queue->next) {
299 (*pnode)->queue = (*pnode)->queue->next;
305 assert(task->
exec == exec_);
306 (*exec->impl)->post(exec->impl, task);
307 ev_std_exec_on_task_fini(exec_);
313 ev_std_exec_from_exec(
const ev_exec_t *exec)
323 while (*
pnode && (*pnode)->exec != exec)
This header file is part of the utilities library; it contains the native and platform-independent er...
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
This header file is part of the event library; it contains the abstract task executor interface.
#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.
This is the public header file of the utilities library.
#define structof(ptr, type, member)
Obtains the address of a structure from the address of one of its members.
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 event library; it contains the standard executor declarations.
This header file is part of the C11 and POSIX compatibility library; it includes <stdint....
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
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 node in a pairing heap.
struct pnode * next
A pointer to the next sibling node.
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.