Lely core libraries  2.3.4
poll.h
Go to the documentation of this file.
1 
24 #ifndef LELY_IO2_WIN32_POLL_H_
25 #define LELY_IO2_WIN32_POLL_H_
26 
27 #include <lely/ev/poll.h>
28 #include <lely/io2/ctx.h>
29 #include <lely/io2/sys/io.h>
30 
31 #include <windows.h>
32 
33 struct io_cp;
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
47 typedef void io_cp_func_t(struct io_cp *cp, size_t nbytes, int errc);
48 
54 struct io_cp {
63  OVERLAPPED overlapped;
64 };
65 
67 #define IO_CP_INIT(func) \
68  { \
69  (func), { 0, 0, { { 0, 0 } }, NULL } \
70  }
71 
72 void *io_poll_alloc(void);
73 void io_poll_free(void *ptr);
74 io_poll_t *io_poll_init(io_poll_t *poll, io_ctx_t *ctx);
75 void io_poll_fini(io_poll_t *poll);
76 
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 
116 int io_poll_register_handle(io_poll_t *poll, HANDLE handle);
117 
132 int io_poll_post(io_poll_t *poll, size_t nbytes, struct io_cp *cp);
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif // !LELY_IO2_WIN32_POLL_H_
This header file is part of the I/O library; it contains the I/O context and service declarations.
This header file is part of the event library; it contains the abstract polling interface.
const struct ev_poll_vtbl *const ev_poll_t
The abstract polling interface.
Definition: poll.h:32
This header file is part of the I/O library; it contains system-dependent I/O initialization/finaliza...
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
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
void io_cp_func_t(struct io_cp *cp, size_t nbytes, int errc)
The type of function invoked by an I/O polling instance (through ev_poll_wait()) when an overlapped I...
Definition: poll.h:47
int io_poll_register_handle(io_poll_t *poll, HANDLE handle)
Registers a file handle with (the I/O completion port of) an I/O polling instance.
int io_poll_post(io_poll_t *poll, size_t nbytes, struct io_cp *cp)
Posts a completion packet to the I/O completion port of an I/O polling instance.
io_poll_t * io_poll_create(void)
Creates a new I/O polling interface.
Definition: poll.c:218
void io_poll_destroy(io_poll_t *poll)
Destroys an I/O polling interface.
Definition: poll.c:243
An I/O polling interface.
Definition: poll.c:51
An I/O completion packet.
Definition: poll.h:54
io_cp_func_t * func
A pointer to the function to be invoked when the I/O operation completes.
Definition: poll.h:59
OVERLAPPED overlapped
The OVERLAPPED structure submitted to the asynchronous I/O operation.
Definition: poll.h:63
Definition: ctx.c:38