diff options
Diffstat (limited to 'include/libtf/io.h')
-rw-r--r-- | include/libtf/io.h | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/include/libtf/io.h b/include/libtf/io.h index 0d34421..d1098e3 100644 --- a/include/libtf/io.h +++ b/include/libtf/io.h @@ -21,10 +21,12 @@ #include <libtf/defines.h> /* Flags for tf_open_fd() */ -#define TF_FD_AUTOCLOSE 1 -#define TF_FD_STREAM_ORIENTED 2 -#define TF_FD_SET_CLOEXEC 4 -#define TF_FD_ALREADY_NONBLOCKING 8 +#define TF_FD_READ TF_BIT(0) +#define TF_FD_WRITE TF_BIT(1) +#define TF_FD_AUTOCLOSE TF_BIT(2) +#define TF_FD_STREAM_ORIENTED TF_BIT(3) +#define TF_FD_SET_CLOEXEC TF_BIT(4) +#define TF_FD_ALREADY_NONBLOCKING TF_BIT(5) struct tf_sockaddr { union { @@ -37,23 +39,14 @@ struct tf_sockaddr { struct tf_fd { int fd; unsigned int flags; - /* Single waiter -- would be relatively trivial to modify to allow - * multiple waiters, if someone actually needs it */ - unsigned int events; - void *waiting_fiber; + struct tf_fiber *fiber; }; -#define TF_POLL_READ 1 -#define TF_POLL_WRITE 2 - struct tf_poll_hooks { - void (*init)(void); - int (*poll)(tf_mtime_diff_t timeout); - void (*close)(void); - int (*fd_created)(struct tf_fd *fd); - int (*fd_destroyed)(struct tf_fd *fd); - void (*fd_monitor)(struct tf_fd *fd, int events); - void (*fd_unmonitor)(struct tf_fd *fd); + void * (*create)(void); + int (*fd_created)(void *fiber, struct tf_fd *fd); + int (*fd_destroyed)(void *fiber, struct tf_fd *fd); + void (*fd_rearm)(void *fiber, struct tf_fd *fd); }; int tf_open_fd(struct tf_fd *fd, int kfd, int flags); |