- return value cleanup
[strongswan.git] / Source / charon / queues / 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 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 <queues/jobs/job.h>
28
29 typedef struct job_queue_t job_queue_t;
30
31 /**
32 * @brief Job-Queue
33 *
34 * Although the job-queue is based on a linked_list_t
35 * all access functions are thread-save implemented
36 */
37 struct job_queue_t {
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 * After using, the returned job has to get destroyed by the caller.
52 *
53 * @param job_queue_t calling object
54 * @param[out] job pointer to a job pointer where to job is returned to
55 * @return job
56 */
57 job_t *(*get) (job_queue_t *job_queue);
58
59 /**
60 * @brief adds a job to the queue
61 *
62 * This function is non blocking and adds a job_t to the list.
63 * The specific job object has to get destroyed by the thread which
64 * removes the job.
65 *
66 * @param job_queue_t calling object
67 * @param[in] job job to add to the queue (job is not copied)
68 */
69 void (*add) (job_queue_t *job_queue, job_t *job);
70
71 /**
72 * @brief destroys a job_queue object
73 *
74 * @warning The caller of this function has to make sure
75 * that no thread is going to add or get a job from the job_queue
76 * after calling this function.
77 *
78 * @param job_queue_t calling object
79 */
80 void (*destroy) (job_queue_t *job_queue);
81 };
82
83 /**
84 * @brief Creates an empty job_queue
85 *
86 * @return job_queue_t empty job_queue
87 */
88 job_queue_t *job_queue_create();
89
90 #endif /*JOB_QUEUE_H_*/