summaryrefslogtreecommitdiff
path: root/io_muxer.h
diff options
context:
space:
mode:
authorMikhail Burakov <mburakov@mailbox.org>2022-12-25 13:50:41 +0100
committerMikhail Burakov <mburakov@mailbox.org>2022-12-25 13:50:41 +0100
commitd58fcf64d9e7a3f309a706ce6a81eb9a41eb5348 (patch)
tree56ce15a6d0a006d8c8d5e01144216d8d2d46e5f0 /io_muxer.h
parent3f1e645ee1410d90b493b2e0034e25d68bd0d3eb (diff)
Cosmetic rework of toolbox
Diffstat (limited to 'io_muxer.h')
-rw-r--r--io_muxer.h30
1 files changed, 18 insertions, 12 deletions
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 <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_