blob: d09efae2c8ab5df435856ac2dd58525f45e09034 [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
Willy Tarreaubaaee002006-06-26 02:48:02 +020025#include <sys/time.h>
26
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020027#include <common/config.h>
Willy Tarreau964c9362007-01-07 00:38:00 +010028#include <common/rbtree.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020029
30/* values for task->state */
31#define TASK_IDLE 0
32#define TASK_RUNNING 1
33
34/* The base for all tasks */
35struct task {
Willy Tarreau964c9362007-01-07 00:38:00 +010036 struct rb_node rb_node;
37 struct rb_root *wq;
Willy Tarreaubaaee002006-06-26 02:48:02 +020038 struct task *rqnext; /* chaining in run queue ... */
Willy Tarreaubaaee002006-06-26 02:48:02 +020039 int state; /* task state : IDLE or RUNNING */
40 struct timeval expire; /* next expiration time for this task, use only for fast sorting */
41 int (*process)(struct task *t); /* the function which processes the task */
42 void *context; /* the task's context */
43};
44
45#define sizeof_task sizeof(struct task)
46extern void **pool_task;
47
Willy Tarreau964c9362007-01-07 00:38:00 +010048extern struct rb_root wait_queue[2];
Willy Tarreaubaaee002006-06-26 02:48:02 +020049extern struct task *rq;
50
51
52#endif /* _TYPES_TASK_H */
53
54/*
55 * Local variables:
56 * c-indent-level: 8
57 * c-basic-offset: 8
58 * End:
59 */