Lely core libraries  2.2.5
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
80 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_
This is the public header file of the I/O library.
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:249
io_poll_t * io_poll_create(void)
Creates a new I/O polling interface.
Definition: poll.c:215
void io_poll_destroy(io_poll_t *poll)
Destroys an I/O polling interface.
Definition: poll.c:240
@ 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
An event signaling that a file descriptor is ready for writing normal-priority (non-OOB) data.
Definition: poll.h:46
@ IO_EVENT_SIGNAL
An event representing the occurrence of a signal.
Definition: poll.h:29
@ IO_EVENT_ERROR
An event signaling that an error has occurred for a file descriptor.
Definition: poll.h:36
int io_poll_signal(io_poll_t *poll, unsigned char sig)
Generates a signal event.
Definition: poll.c:590
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:349
An I/O polling interface.
Definition: poll.c:48
An I/O event.
Definition: poll.h:50
io_handle_t handle
An I/O device handle (if events != IO_EVENT_SIGNAL).
Definition: poll.h:67
unsigned char sig
The signal number (if events == IO_EVENT_SIGNAL).
Definition: poll.h:60
void * data
A pointer to user-specified data (if events != IO_EVENT_SIGNAL).
Definition: poll.h:65
int events
The events that should be watched or have been triggered (either IO_EVENT_SIGNAL, or any combination ...
Definition: poll.h:56
union io_event::@13 u
Signal attributes depending on the value of events.
An I/O device handle.
Definition: handle.h:41