blob: 560a2fc68c97a72f79c12b091126819e1ed43992 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
2 include/types/task.h
3 Macros, variables and structures for task management.
4
5 Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#ifndef _TYPES_TASK_H
23#define _TYPES_TASK_H
24
25
26#include <sys/time.h>
27
28
29/* values for task->state */
30#define TASK_IDLE 0
31#define TASK_RUNNING 1
32
33/* The base for all tasks */
34struct task {
35 struct task *next, *prev; /* chaining ... */
36 struct task *rqnext; /* chaining in run queue ... */
37 struct task *wq; /* the wait queue this task is in */
38 int state; /* task state : IDLE or RUNNING */
39 struct timeval expire; /* next expiration time for this task, use only for fast sorting */
40 int (*process)(struct task *t); /* the function which processes the task */
41 void *context; /* the task's context */
42};
43
44#define sizeof_task sizeof(struct task)
45extern void **pool_task;
46
47extern struct task wait_queue[2];
48extern struct task *rq;
49
50
51#endif /* _TYPES_TASK_H */
52
53/*
54 * Local variables:
55 * c-indent-level: 8
56 * c-basic-offset: 8
57 * End:
58 */