]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - sched.h
first version of the universal paraslash scheduler
[paraslash.git] / sched.h
diff --git a/sched.h b/sched.h
new file mode 100644 (file)
index 0000000..3de5e1c
--- /dev/null
+++ b/sched.h
@@ -0,0 +1,31 @@
+struct sched {
+       struct timeval now, timeout;
+       int max_fileno;
+       fd_set rfds, wfds;
+       int select_ret;
+       struct timeval default_timeout;
+};
+
+struct task {
+       void *private_data;
+       unsigned flags;
+       int ret;
+       void (*pre_select)(struct sched *s, struct task *t);
+       void (*post_select)(struct sched *s, struct task *t);
+       void (*error_handler)(struct task *t);
+       struct list_head pre_select_node;
+       struct list_head post_select_node;
+       char status[MAXLINE];
+};
+
+enum task_flags {
+       PRE_ADD_TAIL = 1,
+       POST_ADD_TAIL = 2,
+       PRE_EOF_IS_ERROR = 4,
+       POST_EOF_IS_ERROR = 8,
+};
+
+void *register_task(struct task *t);
+void unregister_task(struct task *t);
+int sched(struct sched *s);
+void init_sched(void);