Lely core libraries  2.3.4
poll.h
Go to the documentation of this file.
1 
22 #ifndef LELY_IO_POLL_H_
23 #define LELY_IO_POLL_H_
24 
25 #include <lely/io/io.h>
26 
27 enum {
36  IO_EVENT_ERROR = 1 << 0,
41  IO_EVENT_READ = 1 << 1,
46  IO_EVENT_WRITE = 1 << 2
47 };
48 
50 struct io_event {
56  int events;
58  union {
60  unsigned char sig;
65  void *data;
68  } u;
69 };
70 
72 #define IO_EVENT_INIT \
73  { \
74  0, { 0 } \
75  }
76 
77 struct __io_poll;
78 #ifndef __cplusplus
79 typedef struct __io_poll io_poll_t;
81 #endif
82 
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
87 void *__io_poll_alloc(void);
88 void __io_poll_free(void *ptr);
89 struct __io_poll *__io_poll_init(struct __io_poll *poll);
90 void __io_poll_fini(struct __io_poll *poll);
91 
94 
96 void io_poll_destroy(io_poll_t *poll);
97 
116 int io_poll_watch(io_poll_t *poll, io_handle_t handle, struct io_event *event,
117  int keep);
118 
142 int io_poll_wait(io_poll_t *poll, int maxevents, struct io_event *events,
143  int timeout);
144 
156 int io_poll_signal(io_poll_t *poll, unsigned char sig);
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif // !LELY_IO_POLL_H_
IO_EVENT_ERROR
@ IO_EVENT_ERROR
An event signaling that an error has occurred for a file descriptor.
Definition: poll.h:36
io_poll_destroy
void io_poll_destroy(io_poll_t *poll)
Destroys an I/O polling interface.
Definition: poll.c:243
IO_EVENT_READ
@ IO_EVENT_READ
An event signaling that a file descriptor is ready for reading normal-priority (non-OOB) data.
Definition: poll.h:41
IO_EVENT_WRITE
@ IO_EVENT_WRITE
An event signaling that a file descriptor is ready for writing normal-priority (non-OOB) data.
Definition: poll.h:46
io_event::sig
unsigned char sig
The signal number (if events == IO_EVENT_SIGNAL).
Definition: poll.h:60
io_event::u
union io_event::@13 u
Signal attributes depending on the value of events.
io_handle
An I/O device handle.
Definition: handle.h:33
io_event
An I/O event.
Definition: poll.h:50
io_event::handle
io_handle_t handle
An I/O device handle (if events != IO_EVENT_SIGNAL).
Definition: poll.h:67
io.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_event::events
int events
The events that should be watched or have been triggered (either IO_EVENT_SIGNAL, or any combination ...
Definition: poll.h:56
io_poll_signal
int io_poll_signal(io_poll_t *poll, unsigned char sig)
Generates a signal event.
Definition: poll.c:593
IO_EVENT_SIGNAL
@ IO_EVENT_SIGNAL
An event representing the occurrence of a signal.
Definition: poll.h:29
io_event::data
void * data
A pointer to user-specified data (if events != IO_EVENT_SIGNAL).
Definition: poll.h:65
io_poll_create
io_poll_t * io_poll_create(void)
Creates a new I/O polling interface.
Definition: poll.c:218
io_poll_wait
int io_poll_wait(io_poll_t *poll, int maxevents, struct io_event *events, int timeout)
Waits at most timeout milliseconds for at most maxevents I/O events to occur for any of the I/O devic...
Definition: poll.c:352