diff options
author | Mikhail Burakov <mburakov@mailbox.org> | 2022-12-25 13:50:41 +0100 |
---|---|---|
committer | Mikhail Burakov <mburakov@mailbox.org> | 2022-12-25 13:50:41 +0100 |
commit | d58fcf64d9e7a3f309a706ce6a81eb9a41eb5348 (patch) | |
tree | 56ce15a6d0a006d8c8d5e01144216d8d2d46e5f0 /io_muxer.h | |
parent | 3f1e645ee1410d90b493b2e0034e25d68bd0d3eb (diff) |
Cosmetic rework of toolbox
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_ |