diff options
Diffstat (limited to 'io_muxer.h')
-rw-r--r-- | io_muxer.h | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -15,9 +15,10 @@ * along with toolbox. If not, see <https://www.gnu.org/licenses/>. */ -#ifndef IO_MUXER_H_ -#define IO_MUXER_H_ +#ifndef TOOLBOX_IO_MUXER_H_ +#define TOOLBOX_IO_MUXER_H_ +#include <stdbool.h> #include <stddef.h> #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_ |