Lely core libraries  2.3.4
dev.h
Go to the documentation of this file.
1 
22 #ifndef LELY_IO2_DEV_H_
23 #define LELY_IO2_DEV_H_
24 
25 #include <lely/ev/ev.h>
26 #include <lely/io2/io2.h>
27 
28 #include <stddef.h>
29 
30 #ifndef LELY_IO_DEV_INLINE
31 #define LELY_IO_DEV_INLINE static inline
32 #endif
33 
35 typedef const struct io_dev_vtbl *const io_dev_t;
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 struct io_dev_vtbl {
42  io_ctx_t *(*get_ctx)(const io_dev_t *dev);
43  ev_exec_t *(*get_exec)(const io_dev_t *dev);
44  size_t (*cancel)(io_dev_t *dev, struct ev_task *task);
45  size_t (*abort)(io_dev_t *dev, struct ev_task *task);
46 };
47 
51 LELY_IO_DEV_INLINE io_ctx_t *io_dev_get_ctx(const io_dev_t *dev);
52 
57 LELY_IO_DEV_INLINE ev_exec_t *io_dev_get_exec(const io_dev_t *dev);
58 
68 LELY_IO_DEV_INLINE size_t io_dev_cancel(io_dev_t *dev, struct ev_task *task);
69 
77 LELY_IO_DEV_INLINE size_t io_dev_abort(io_dev_t *dev, struct ev_task *task);
78 
79 inline io_ctx_t *
81 {
82  return (*dev)->get_ctx(dev);
83 }
84 
85 inline ev_exec_t *
87 {
88  return (*dev)->get_exec(dev);
89 }
90 
91 inline size_t
92 io_dev_cancel(io_dev_t *dev, struct ev_task *task)
93 {
94  return (*dev)->cancel(dev, task);
95 }
96 
97 inline size_t
98 io_dev_abort(io_dev_t *dev, struct ev_task *task)
99 {
100  return (*dev)->abort(dev, task);
101 }
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif // !LELY_IO2_DEV_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 is the public header file of the I/O library.
size_t io_dev_abort(io_dev_t *dev, struct ev_task *task)
Aborts the asynchronous operation submitted to *dev, if its task has not yet been submitted to its ex...
Definition: dev.h:98
const struct io_dev_vtbl *const io_dev_t
An abstract I/O device.
Definition: dev.h:35
io_ctx_t * io_dev_get_ctx(const io_dev_t *dev)
Returns a pointer to the I/O context with which the I/O device is registered.
Definition: dev.h:80
size_t io_dev_cancel(io_dev_t *dev, struct ev_task *task)
Cancels the asynchronous operation submitted to *dev, if its task has not yet been submitted to its e...
Definition: dev.h:92
ev_exec_t * io_dev_get_exec(const io_dev_t *dev)
Returns a pointer to the executor used by the I/O device to execute asynchronous tasks.
Definition: dev.h:86
This header file is part of the C11 and POSIX compatibility library; it includes <stddef....
An executable task.
Definition: task.h:41
Definition: ctx.c:38