Allow adding an event callback
This commit is contained in:
@@ -63,18 +63,40 @@ struct io_operation {
|
||||
#endif
|
||||
};
|
||||
|
||||
enum io_evtype {
|
||||
IO_ERROR,
|
||||
IO_ABORT,
|
||||
IO_COMPLETE,
|
||||
};
|
||||
|
||||
struct io_event {
|
||||
enum io_evtype evtype;
|
||||
enum io_optype optype;
|
||||
io_handle handle;
|
||||
void *user;
|
||||
|
||||
union {
|
||||
uint32_t num;
|
||||
io_handle accepted;
|
||||
};
|
||||
};
|
||||
|
||||
enum io_restype {
|
||||
IO_RES_VOID,
|
||||
IO_RES_FILE,
|
||||
IO_RES_SOCKET,
|
||||
};
|
||||
|
||||
typedef void (*io_callback)(struct io_event);
|
||||
|
||||
struct io_resource {
|
||||
enum io_restype type;
|
||||
io_os_handle os_handle;
|
||||
uint16_t pending;
|
||||
uint16_t gen;
|
||||
|
||||
io_callback callback;
|
||||
|
||||
#if IO_PLATFORM_WINDOWS
|
||||
void *acceptfn;
|
||||
char accept_buffer[2 * (IO_SOCKADDR_IN_SIZE + 16)];
|
||||
@@ -121,24 +143,6 @@ struct io_context {
|
||||
#endif
|
||||
};
|
||||
|
||||
enum io_evtype {
|
||||
IO_ERROR,
|
||||
IO_ABORT,
|
||||
IO_COMPLETE,
|
||||
};
|
||||
|
||||
struct io_event {
|
||||
enum io_evtype evtype;
|
||||
enum io_optype optype;
|
||||
io_handle handle;
|
||||
void *user;
|
||||
|
||||
union {
|
||||
uint32_t num;
|
||||
io_handle accepted;
|
||||
};
|
||||
};
|
||||
|
||||
bool io_global_init(void);
|
||||
void io_global_free(void);
|
||||
|
||||
@@ -185,3 +189,7 @@ io_handle io_create_file(struct io_context *ioc,
|
||||
|
||||
io_handle io_start_server(struct io_context *ioc,
|
||||
const char *addr, int port);
|
||||
|
||||
void io_set_callback(struct io_context *ioc,
|
||||
io_handle handle,
|
||||
io_callback callback);
|
||||
Reference in New Issue
Block a user