Lely core libraries  2.3.4
poll.h
Go to the documentation of this file.
1 
22 #ifndef LELY_IO2_POSIX_POLL_H_
23 #define LELY_IO2_POSIX_POLL_H_
24 
25 #include <lely/ev/poll.h>
26 #include <lely/io2/ctx.h>
27 #include <lely/io2/event.h>
28 #include <lely/io2/sys/io.h>
29 #include <lely/util/rbtree.h>
30 
31 struct io_poll_watch;
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
48 typedef void io_poll_watch_func_t(struct io_poll_watch *watch, int events);
49 
56 struct io_poll_watch {
59  int _fd;
60  struct rbnode _node;
61  int _events;
62 };
63 
65 #define IO_POLL_WATCH_INIT(func) \
66  { \
67  (func), -1, RBNODE_INIT, 0 \
68  }
69 
70 void *io_poll_alloc(void);
71 void io_poll_free(void *ptr);
72 io_poll_t *io_poll_init(io_poll_t *poll, io_ctx_t *ctx, int signo);
73 void io_poll_fini(io_poll_t *poll);
74 
87 io_poll_t *io_poll_create(io_ctx_t *ctx, int signo);
88 
90 void io_poll_destroy(io_poll_t *poll);
91 
96 io_ctx_t *io_poll_get_ctx(const io_poll_t *poll);
97 
102 ev_poll_t *io_poll_get_poll(const io_poll_t *poll);
103 
124 int io_poll_watch(io_poll_t *poll, int fd, int events,
125  struct io_poll_watch *watch);
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif // !LELY_IO2_POSIX_POLL_H_
ctx.h
io_poll_destroy
void io_poll_destroy(io_poll_t *poll)
Destroys an I/O polling interface.
Definition: poll.c:243
ev_poll_t
const struct ev_poll_vtbl *const ev_poll_t
The abstract polling interface.
Definition: poll.h:32
io_poll_watch
An object representing a file descriptor being monitored for I/O events.
Definition: poll.h:56
io_poll_get_poll
ev_poll_t * io_poll_get_poll(const io_poll_t *poll)
Returns a pointer to the ev_poll_t instance corresponding to the I/O polling instance.
Definition: poll.c:281
io.h
io_poll_watch::func
io_poll_watch_func_t * func
A pointer to the function to be invoked when an I/O event occurs.
Definition: poll.h:58
poll.h
__io_poll
An I/O polling interface.
Definition: poll.c:51
io_poll_watch
int io_poll_watch(io_poll_t *poll, io_handle_t handle, struct io_event *event, int keep)
Registers an I/O device with an I/O polling interface and instructs it to watch for certain events.
Definition: poll.c:252
io_poll_get_ctx
io_ctx_t * io_poll_get_ctx(const io_poll_t *poll)
Returns a pointer to the I/O context with which the I/O polling instance is registered.
Definition: poll.c:275
rbtree.h
event.h
rbnode
A node in a red-black tree.
Definition: rbtree.h:53
io_poll_create
io_poll_t * io_poll_create(void)
Creates a new I/O polling interface.
Definition: poll.c:218
io_ctx
Definition: ctx.c:38
io_poll_watch_func_t
void io_poll_watch_func_t(struct io_poll_watch *watch, int events)
The type of function invoked by an I/O polling instance (through ev_poll_wait()) to report I/O events...
Definition: poll.h:48