Lely core libraries 2.3.4
task.c
Go to the documentation of this file.
1
24#include "ev.h"
25#include <lely/ev/exec.h>
26#include <lely/ev/task.h>
27#include <lely/util/util.h>
28
29#include <stdint.h>
30
31struct ev_task *
33{
34 return node ? structof(node, struct ev_task, _node) : NULL;
35}
36
37size_t
39{
40 size_t n = 0;
41
42 struct slnode *node;
43 while ((node = sllist_pop_front(queue))) {
44 struct ev_task *task = ev_task_from_node(node);
45 ev_exec_t *exec = task->exec;
46 ev_exec_post(exec, task);
48 n += n < SIZE_MAX;
49 }
50
51 return n;
52}
53
54size_t
56{
57 size_t n = 0;
58
59 struct slnode *node;
60 while ((node = sllist_pop_front(queue))) {
61 struct ev_task *task = ev_task_from_node(node);
63 n += n < SIZE_MAX;
64 }
65
66 return n;
67}
This header file is part of the event library; it contains the abstract task executor interface.
void ev_exec_post(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:124
void ev_exec_on_task_fini(ev_exec_t *exec)
Undoes the effect of a previous call to ev_exec_on_task_init().
Definition: exec.h:112
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
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.
Definition: util.h:93
struct slnode * sllist_pop_front(struct sllist *list)
Pops a node from the front of a singly-linked list.
Definition: sllist.h:243
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....
An executable task.
Definition: task.h:41
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
Definition: task.h:43
A singly-linked list.
Definition: sllist.h:52
A node in a singly-linked list.
Definition: sllist.h:40
size_t ev_task_queue_abort(struct sllist *queue)
Aborts the tasks in queue by invoking ev_exec_on_task_fini() for each of them.
Definition: task.c:55
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.
Definition: task.c:32
size_t ev_task_queue_post(struct sllist *queue)
Post the tasks in queue to their respective executors and invokes ev_exec_on_task_fini() for each of ...
Definition: task.c:38
This header file is part of the event library; it contains the task declarations.