]>
git.ipfire.org Git - thirdparty/strongswan.git/blob - src/charon/processing/job_queue.h
4 * @brief Interface of job_queue_t.
9 * Copyright (C) 2005-2006 Martin Willi
10 * Copyright (C) 2005 Jan Hutter
11 * Hochschule fuer Technik Rapperswil
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>.
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
27 typedef struct job_queue_t job_queue_t
;
30 #include <processing/jobs/job.h>
33 * @brief The job queue stores jobs, which will be processed by the thread_pool_t.
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.
41 * - job_queue_create()
48 * @brief Returns number of jobs in queue.
50 * @param job_queue_t calling object
51 * @returns number of items in queue
53 int (*get_count
) (job_queue_t
*job_queue
);
56 * @brief Get the next job from the queue.
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.
61 * @param job_queue_t calling object
62 * @param[out] job pointer to a job pointer where to job is returned to
65 job_t
*(*get
) (job_queue_t
*job_queue
);
68 * @brief Adds a job to the queue.
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
74 * @param job_queue_t calling object
75 * @param job job to add to the queue (job is not copied)
77 void (*add
) (job_queue_t
*job_queue
, job_t
*job
);
80 * @brief Destroys a job_queue object.
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.
86 * @param job_queue_t calling object
88 void (*destroy
) (job_queue_t
*job_queue
);
92 * @brief Creates an empty job_queue.
94 * @return job_queue_t object
98 job_queue_t
*job_queue_create(void);
100 #endif /*JOB_QUEUE_H_*/