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