Lely core libraries  2.3.4
task.h
Go to the documentation of this file.
1 
22 #ifndef LELY_EV_TASK_H_
23 #define LELY_EV_TASK_H_
24 
25 #include <lely/ev/ev.h>
26 #include <lely/util/sllist.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
33 typedef void ev_task_func_t(struct ev_task *task);
34 
41 struct ev_task {
46  // The node of this task in a queue.
47  struct slnode _node;
48  // A pointer used to store additional data while processing a task.
49  void *_data;
50 };
51 
53 #define EV_TASK_INIT(exec, func) \
54  { \
55  (exec), (func), SLNODE_INIT, NULL \
56  }
57 
64 struct ev_task *ev_task_from_node(struct slnode *node);
65 
72 size_t ev_task_queue_post(struct sllist *queue);
73 
80 size_t ev_task_queue_abort(struct sllist *queue);
81 
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif // !LELY_EV_TASK_H_
This is the public header file of the event library.
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
This header file is part of the utilities library; it contains the singly-linked list declarations.
An executable task.
Definition: task.h:41
ev_task_func_t * func
The function to be invoked when the task is run.
Definition: task.h:45
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
void ev_task_func_t(struct ev_task *task)
The type of function invoked by an executor when a task is run.
Definition: task.h:33
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