d25cee03ea9bd19baebc3708483fdc8d1a6a35cc
[strongswan.git] / src / libstrongswan / processing / jobs / job.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 /**
18 * @defgroup job job
19 * @{ @ingroup jobs
20 */
21
22 #ifndef JOB_H_
23 #define JOB_H_
24
25 typedef struct job_t job_t;
26 typedef enum job_priority_t job_priority_t;
27
28 #include <library.h>
29
30 /**
31 * Priority classes of jobs
32 */
33 enum job_priority_t {
34 /** Critical infrastructure jobs that should always been served */
35 JOB_PRIO_CRITICAL = 0,
36 /** Short jobs executed with highest priority */
37 JOB_PRIO_HIGH,
38 /** Default job priority */
39 JOB_PRIO_MEDIUM,
40 /** Low priority jobs with thread blocking operations */
41 JOB_PRIO_LOW,
42 JOB_PRIO_MAX
43 };
44
45 /**
46 * Enum names for job priorities
47 */
48 extern enum_name_t *job_priority_names;
49
50 /**
51 * Job interface as it is stored in the job queue.
52 */
53 struct job_t {
54
55 /**
56 * Execute a job.
57 *
58 * The processing facility executes a job using this method. Jobs are
59 * one-shot, they destroy themself after execution, so don't use a job
60 * once it has been executed.
61 */
62 void (*execute) (job_t *this);
63
64 /**
65 * Get the priority of a job.
66 *
67 * @return job priority
68 */
69 job_priority_t (*get_priority)(job_t *this);
70
71 /**
72 * Destroy a job.
73 *
74 * Is only called whenever a job was not executed (e.g. due daemon shutdown).
75 * After execution, jobs destroy themself.
76 */
77 void (*destroy) (job_t *this);
78 };
79
80 #endif /** JOB_H_ @}*/