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 | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 28 | #include <common/mini-clist.h> |
| 29 | #include <import/tree.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 30 | |
| 31 | /* values for task->state */ |
| 32 | #define TASK_IDLE 0 |
| 33 | #define TASK_RUNNING 1 |
| 34 | |
| 35 | /* The base for all tasks */ |
| 36 | struct task { |
Willy Tarreau | 96bcfd7 | 2007-04-29 10:41:56 +0200 | [diff] [blame] | 37 | struct list qlist; /* chaining in the same queue; bidirectionnal but not circular */ |
| 38 | struct ultree *wq; /* NULL if unqueued, or back ref to the carrier node in the WQ */ |
| 39 | int state; /* task state : IDLE or RUNNING */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 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 | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 48 | #endif /* _TYPES_TASK_H */ |
| 49 | |
| 50 | /* |
| 51 | * Local variables: |
| 52 | * c-indent-level: 8 |
| 53 | * c-basic-offset: 8 |
| 54 | * End: |
| 55 | */ |