From d58fcf64d9e7a3f309a706ce6a81eb9a41eb5348 Mon Sep 17 00:00:00 2001 From: Mikhail Burakov Date: Sun, 25 Dec 2022 13:50:41 +0100 Subject: Cosmetic rework of toolbox --- io_muxer.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'io_muxer.h') diff --git a/io_muxer.h b/io_muxer.h index 1a1c75d..8fbfc85 100644 --- a/io_muxer.h +++ b/io_muxer.h @@ -15,9 +15,10 @@ * along with toolbox. If not, see . */ -#ifndef IO_MUXER_H_ -#define IO_MUXER_H_ +#ifndef TOOLBOX_IO_MUXER_H_ +#define TOOLBOX_IO_MUXER_H_ +#include #include #ifdef __cplusplus @@ -25,25 +26,30 @@ extern "C" { #endif // __cplusplus struct pollfd; -struct IoMuxer_Closure; +struct IoMuxerTask; struct IoMuxer { struct pollfd* pfds; - struct IoMuxer_Closure* closures; + struct IoMuxerTask* tasks; size_t alloc; size_t size; }; -void IoMuxer_Create(struct IoMuxer* io_muxer); -int IoMuxer_OnRead(struct IoMuxer* io_muxer, int fd, - void (*read_callback)(void*), void* user); -int IoMuxer_OnWrite(struct IoMuxer* io_muxer, int fd, - void (*write_callback)(void*), void* user); -int IoMuxer_Iterate(struct IoMuxer* io_muxer, int timeout); -void IoMuxer_Destroy(struct IoMuxer* io_muxer); +enum IoMuxerResult { + kIoMuxerResultError = 0, + kIoMuxerResultTimeout, +}; + +void IoMuxerCreate(struct IoMuxer* io_muxer); +bool IoMuxerOnRead(struct IoMuxer* io_muxer, int fd, void (*fun)(void*), + void* user); +bool IoMuxerOnWrite(struct IoMuxer* io_muxer, int fd, void (*fun)(void*), + void* user); +enum IoMuxerResult IoMuxerIterate(struct IoMuxer* io_muxer, int timeout); +void IoMuxerDestroy(struct IoMuxer* io_muxer); #ifdef __cplusplus } // extern "C" #endif // __cplusplus -#endif // IO_MUXER_H_ +#endif // TOOLBOX_IO_MUXER_H_ -- cgit v1.2.3