Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 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 Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 25 | #include <sys/time.h> |
| 26 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 27 | #include <common/config.h> |
Willy Tarreau | 964c936 | 2007-01-07 00:38:00 +0100 | [diff] [blame] | 28 | #include <common/rbtree.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 29 | |
| 30 | /* values for task->state */ |
| 31 | #define TASK_IDLE 0 |
| 32 | #define TASK_RUNNING 1 |
| 33 | |
| 34 | /* The base for all tasks */ |
| 35 | struct task { |
Willy Tarreau | 964c936 | 2007-01-07 00:38:00 +0100 | [diff] [blame] | 36 | struct rb_node rb_node; |
| 37 | struct rb_root *wq; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 38 | struct task *rqnext; /* chaining in run queue ... */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 39 | 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) |
| 46 | extern void **pool_task; |
| 47 | |
Willy Tarreau | 964c936 | 2007-01-07 00:38:00 +0100 | [diff] [blame] | 48 | extern struct rb_root wait_queue[2]; |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 49 | extern 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 | */ |