Lely core libraries  2.3.4
exec.h
Go to the documentation of this file.
1 
22 #ifndef LELY_EV_EXEC_H_
23 #define LELY_EV_EXEC_H_
24 
25 #include <lely/ev/ev.h>
26 
27 #include <stddef.h>
28 
29 #ifndef LELY_EV_EXEC_INLINE
30 #define LELY_EV_EXEC_INLINE static inline
31 #endif
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 struct ev_exec_vtbl {
38  void (*on_task_init)(ev_exec_t *exec);
39  void (*on_task_fini)(ev_exec_t *exec);
40  int (*dispatch)(ev_exec_t *exec, struct ev_task *task);
41  void (*post)(ev_exec_t *exec, struct ev_task *task);
42  void (*defer)(ev_exec_t *exec, struct ev_task *task);
43  size_t (*abort)(ev_exec_t *exec, struct ev_task *task);
44  void (*run)(ev_exec_t *exec, struct ev_task *task);
45 };
46 
52 LELY_EV_EXEC_INLINE void ev_exec_on_task_init(ev_exec_t *exec);
53 
55 LELY_EV_EXEC_INLINE void ev_exec_on_task_fini(ev_exec_t *exec);
56 
67 LELY_EV_EXEC_INLINE int ev_exec_dispatch(ev_exec_t *exec, struct ev_task *task);
68 
76 LELY_EV_EXEC_INLINE void ev_exec_post(ev_exec_t *exec, struct ev_task *task);
77 
87 LELY_EV_EXEC_INLINE void ev_exec_defer(ev_exec_t *exec, struct ev_task *task);
88 
95 LELY_EV_EXEC_INLINE size_t ev_exec_abort(ev_exec_t *exec, struct ev_task *task);
96 
103 LELY_EV_EXEC_INLINE void ev_exec_run(ev_exec_t *exec, struct ev_task *task);
104 
105 inline void
107 {
108  (*exec)->on_task_init(exec);
109 }
110 
111 inline void
113 {
114  (*exec)->on_task_fini(exec);
115 }
116 
117 inline int
119 {
120  return (*exec)->dispatch(exec, task);
121 }
122 
123 inline void
125 {
126  (*exec)->post(exec, task);
127 }
128 
129 inline void
131 {
132  (*exec)->defer(exec, task);
133 }
134 
135 inline size_t
137 {
138  return (*exec)->abort(exec, task);
139 }
140 
141 inline void
143 {
144  (*exec)->run(exec, task);
145 }
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif // !LELY_EV_EXEC_H_
ev_exec_t
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
ev_exec_dispatch
int ev_exec_dispatch(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:118
ev_exec_run
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.
Definition: exec.h:142
ev_exec_vtbl
Definition: exec.h:37
ev_exec_on_task_fini
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
ev_exec_abort
size_t ev_exec_abort(ev_exec_t *exec, struct ev_task *task)
Aborts the specified task submitted to *exec, if it has not yet begun executing, or all pending tasks...
Definition: exec.h:136
ev.h
ev_exec_defer
void ev_exec_defer(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:130
ev_task
An executable task.
Definition: task.h:41
ev_exec_on_task_init
void ev_exec_on_task_init(ev_exec_t *exec)
Indicates to the specified executor that a task will be submitted for execution in the future.
Definition: exec.h:106
ev_exec_post
void ev_exec_post(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:124
stddef.h
ev_task::exec
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
Definition: task.h:43