Lely core libraries  2.2.5
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(
68  ev_exec_t *exec, struct ev_task *task);
69 
77 LELY_EV_EXEC_INLINE void ev_exec_post(ev_exec_t *exec, struct ev_task *task);
78 
88 LELY_EV_EXEC_INLINE void ev_exec_defer(ev_exec_t *exec, struct ev_task *task);
89 
96 LELY_EV_EXEC_INLINE size_t ev_exec_abort(
97  ev_exec_t *exec, struct ev_task *task);
98 
105 LELY_EV_EXEC_INLINE void ev_exec_run(ev_exec_t *exec, struct ev_task *task);
106 
107 inline void
109 {
110  (*exec)->on_task_init(exec);
111 }
112 
113 inline void
115 {
116  (*exec)->on_task_fini(exec);
117 }
118 
119 inline int
120 ev_exec_dispatch(ev_exec_t *exec, struct ev_task *task)
121 {
122  return (*exec)->dispatch(exec, task);
123 }
124 
125 inline void
126 ev_exec_post(ev_exec_t *exec, struct ev_task *task)
127 {
128  (*exec)->post(exec, task);
129 }
130 
131 inline void
132 ev_exec_defer(ev_exec_t *exec, struct ev_task *task)
133 {
134  (*exec)->defer(exec, task);
135 }
136 
137 inline size_t
138 ev_exec_abort(ev_exec_t *exec, struct ev_task *task)
139 {
140  return (*exec)->abort(exec, task);
141 }
142 
143 inline void
144 ev_exec_run(ev_exec_t *exec, struct ev_task *task)
145 {
146  (*exec)->run(exec, task);
147 }
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif // !LELY_EV_EXEC_H_
void ev_exec_post(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:126
const struct ev_exec_vtbl *const ev_exec_t
An abstract task executor.
Definition: ev.h:29
void ev_exec_defer(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:132
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:114
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:138
ev_exec_t * exec
A pointer to the executor to which the task is (to be) submitted.
Definition: task.h:43
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:108
This is the public header file of the event library.
This header file is part of the C11 and POSIX compatibility library; it includes <stddef.h> and defines any missing functionality.
An executable task.
Definition: task.h:41
int ev_exec_dispatch(ev_exec_t *exec, struct ev_task *task)
Submits *task to *exec for execution.
Definition: exec.h:120
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:144