]>
git.ipfire.org Git - people/ms/strongswan.git/blob - Source/charon/queues/job_queue.h
4 * @brief Interface of job_queue_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
27 #include <queues/jobs/job.h>
29 typedef struct job_queue_t job_queue_t
;
32 * @brief The job queue stores jobs, which will be processed by the thread_pool_t.
34 * Jobs are added from various sources, from the threads and
35 * from the event_queue_t.
36 * Although the job-queue is based on a linked_list_t
37 * all access functions are thread-save implemented.
40 * - job_queue_create()
47 * @brief Returns number of jobs in queue.
49 * @param job_queue_t calling object
50 * @returns number of items in queue
52 int (*get_count
) (job_queue_t
*job_queue
);
55 * @brief Get the next job from the queue.
57 * If the queue is empty, this function blocks until a job can be returned.
58 * After using, the returned job has to get destroyed by the caller.
60 * @param job_queue_t calling object
61 * @param[out] job pointer to a job pointer where to job is returned to
64 job_t
*(*get
) (job_queue_t
*job_queue
);
67 * @brief Adds a job to the queue.
69 * This function is non blocking and adds a job_t to the list.
70 * The specific job object has to get destroyed by the thread which
73 * @param job_queue_t calling object
74 * @param job job to add to the queue (job is not copied)
76 void (*add
) (job_queue_t
*job_queue
, job_t
*job
);
79 * @brief Destroys a job_queue object.
81 * @warning The caller of this function has to make sure
82 * that no thread is going to add or get a job from the job_queue
83 * after calling this function.
85 * @param job_queue_t calling object
87 void (*destroy
) (job_queue_t
*job_queue
);
91 * @brief Creates an empty job_queue.
93 * @return job_queue_t object
97 job_queue_t
*job_queue_create();
99 #endif /*JOB_QUEUE_H_*/