Introduce priority classes for jobs
[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 /** Short jobs executed with highest priority */
35 JOB_PRIO_HIGH = 0,
36 /** Default job priority */
37 JOB_PRIO_MEDIUM,
38 /** Low priority jobs with thread blocking operations */
39 JOB_PRIO_LOW,
40 JOB_PRIO_MAX
41 };
42
43 /**
44 * Job interface as it is stored in the job queue.
45 */
46 struct job_t {
47
48 /**
49 * Execute a job.
50 *
51 * The processing facility executes a job using this method. Jobs are
52 * one-shot, they destroy themself after execution, so don't use a job
53 * once it has been executed.
54 */
55 void (*execute) (job_t *this);
56
57 /**
58 * Get the priority of a job.
59 *
60 * @return job priority
61 */
62 job_priority_t (*get_priority)(job_t *this);
63
64 /**
65 * Destroy a job.
66 *
67 * Is only called whenever a job was not executed (e.g. due daemon shutdown).
68 * After execution, jobs destroy themself.
69 */
70 void (*destroy) (job_t *this);
71 };
72
73 #endif /** JOB_H_ @}*/