3de5e1cc9ef89f39ed02588d55270c918d097476
[paraslash.git] / sched.h
1 struct sched {
2         struct timeval now, timeout;
3         int max_fileno;
4         fd_set rfds, wfds;
5         int select_ret;
6         struct timeval default_timeout;
7 };
8
9 struct task {
10         void *private_data;
11         unsigned flags;
12         int ret;
13         void (*pre_select)(struct sched *s, struct task *t);
14         void (*post_select)(struct sched *s, struct task *t);
15         void (*error_handler)(struct task *t);
16         struct list_head pre_select_node;
17         struct list_head post_select_node;
18         char status[MAXLINE];
19 };
20
21 enum task_flags {
22         PRE_ADD_TAIL = 1,
23         POST_ADD_TAIL = 2,
24         PRE_EOF_IS_ERROR = 4,
25         POST_EOF_IS_ERROR = 8,
26 };
27
28 void *register_task(struct task *t);
29 void unregister_task(struct task *t);
30 int sched(struct sched *s);
31 void init_sched(void);