From dc34e87746f69994aad893b39ee4cd3dda6e2f7b Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Wed, 10 Mar 2010 19:04:26 +0200 Subject: io: virtualize polling api so we can in future have more polling frameworks than epoll. --- include/libtf/io.h | 15 ++++++++++++--- include/libtf/scheduler.h | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'include/libtf') diff --git a/include/libtf/io.h b/include/libtf/io.h index 1f37d81..0d34421 100644 --- a/include/libtf/io.h +++ b/include/libtf/io.h @@ -43,9 +43,18 @@ struct tf_fd { void *waiting_fiber; }; -void tf_poll_init(void); -int tf_poll(tf_mtime_diff_t timeout); -void tf_poll_close(void); +#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); +}; int tf_open_fd(struct tf_fd *fd, int kfd, int flags); int tf_open(struct tf_fd *fd, const char *pathname, int flags); diff --git a/include/libtf/scheduler.h b/include/libtf/scheduler.h index cc8db70..db5a823 100644 --- a/include/libtf/scheduler.h +++ b/include/libtf/scheduler.h @@ -18,6 +18,8 @@ #include #include +struct tf_poll_hooks; + struct tf_scheduler { struct tf_list_head scheduled_q; struct tf_list_head running_q; @@ -26,6 +28,7 @@ struct tf_scheduler { void * main_fiber; int num_fibers; tf_mtime_t scheduler_time; + struct tf_poll_hooks * poller; unsigned long poll_data[2]; }; -- cgit v1.2.3