diff options
author | Timo Teras <timo.teras@iki.fi> | 2010-03-10 19:04:26 +0200 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2010-03-10 19:04:26 +0200 |
commit | dc34e87746f69994aad893b39ee4cd3dda6e2f7b (patch) | |
tree | c67548704b4f4e942cf8afbf00279bf09d624ac8 /include/libtf | |
parent | 674f1495ab082c8f5a604cbb5a4dadc95b8c7ebb (diff) | |
download | libtf-dc34e87746f69994aad893b39ee4cd3dda6e2f7b.tar.bz2 libtf-dc34e87746f69994aad893b39ee4cd3dda6e2f7b.tar.xz |
io: virtualize polling api
so we can in future have more polling frameworks than epoll.
Diffstat (limited to 'include/libtf')
-rw-r--r-- | include/libtf/io.h | 15 | ||||
-rw-r--r-- | include/libtf/scheduler.h | 3 |
2 files changed, 15 insertions, 3 deletions
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 <libtf/heap.h> #include <libtf/fiber.h> +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]; }; |