blob: 6b56547644364b256b3cc7132db9ac48cb2dd96d [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
Willy Tarreau9789f7b2008-06-24 08:17:16 +02005 Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
Willy Tarreaubaaee002006-06-26 02:48:02 +02006
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 Tarreau9789f7b2008-06-24 08:17:16 +020028#include <common/eb32tree.h>
Willy Tarreau96bcfd72007-04-29 10:41:56 +020029#include <common/mini-clist.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020030
31/* values for task->state */
32#define TASK_IDLE 0
33#define TASK_RUNNING 1
34
35/* The base for all tasks */
36struct task {
Willy Tarreau96bcfd72007-04-29 10:41:56 +020037 struct list qlist; /* chaining in the same queue; bidirectionnal but not circular */
Willy Tarreau9789f7b2008-06-24 08:17:16 +020038 struct eb32_node eb; /* ebtree node used to hold the task in the wait queue */
Willy Tarreau96bcfd72007-04-29 10:41:56 +020039 int state; /* task state : IDLE or RUNNING */
Willy Tarreaubaaee002006-06-26 02:48:02 +020040 struct timeval expire; /* next expiration time for this task, use only for fast sorting */
Willy Tarreaud825eef2007-05-12 22:35:00 +020041 void (*process)(struct task *t, struct timeval *next); /* the function which processes the task */
Willy Tarreaubaaee002006-06-26 02:48:02 +020042 void *context; /* the task's context */
43};
44
Willy Tarreaubaaee002006-06-26 02:48:02 +020045#endif /* _TYPES_TASK_H */
46
47/*
48 * Local variables:
49 * c-indent-level: 8
50 * c-basic-offset: 8
51 * End:
52 */