]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/charon/processing/job_queue.h
adapt evaltest to changed debug output
[thirdparty/strongswan.git] / src / charon / processing / job_queue.h
1 /**
2 * @file job_queue.h
3 *
4 * @brief Interface of job_queue_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 */
23
24 #ifndef JOB_QUEUE_H_
25 #define JOB_QUEUE_H_
26
27 typedef struct job_queue_t job_queue_t;
28
29 #include <library.h>
30 #include <processing/jobs/job.h>
31
32 /**
33 * @brief The job queue stores jobs, which will be processed by the thread_pool_t.
34 *
35 * Jobs are added from various sources, from the threads and
36 * from the event_queue_t.
37 * Although the job-queue is based on a linked_list_t
38 * all access functions are thread-save implemented.
39 *
40 * @b Constructors:
41 * - job_queue_create()
42 *
43 * @ingroup queues
44 */
45 struct job_queue_t {
46
47 /**
48 * @brief Returns number of jobs in queue.
49 *
50 * @param job_queue_t calling object
51 * @returns number of items in queue
52 */
53 int (*get_count) (job_queue_t *job_queue);
54
55 /**
56 * @brief Get the next job from the queue.
57 *
58 * If the queue is empty, this function blocks until a job can be returned.
59 * After using, the returned job has to get destroyed by the caller.
60 *
61 * @param job_queue_t calling object
62 * @param[out] job pointer to a job pointer where to job is returned to
63 * @return next job
64 */
65 job_t *(*get) (job_queue_t *job_queue);
66
67 /**
68 * @brief Adds a job to the queue.
69 *
70 * This function is non blocking and adds a job_t to the list.
71 * The specific job object has to get destroyed by the thread which
72 * removes the job.
73 *
74 * @param job_queue_t calling object
75 * @param job job to add to the queue (job is not copied)
76 */
77 void (*add) (job_queue_t *job_queue, job_t *job);
78
79 /**
80 * @brief Destroys a job_queue object.
81 *
82 * @warning The caller of this function has to make sure
83 * that no thread is going to add or get a job from the job_queue
84 * after calling this function.
85 *
86 * @param job_queue_t calling object
87 */
88 void (*destroy) (job_queue_t *job_queue);
89 };
90
91 /**
92 * @brief Creates an empty job_queue.
93 *
94 * @return job_queue_t object
95 *
96 * @ingroup queues
97 */
98 job_queue_t *job_queue_create(void);
99
100 #endif /*JOB_QUEUE_H_*/