4 * @brief Job-Queue based on linked_list_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
26 #include "linked_list.h"
31 typedef enum job_type_e job_type_t
;
35 * Job is to process an incoming IKEv2-Message
39 * Job is to retransmit an IKEv2-Message
43 * Job is to establish an ike sa as initiator
50 * @brief Job like it is represented in the job queue
52 typedef struct job_s job_t
;
58 * Every job has its assigned_data
63 * @brief Destroys a job_t object
65 * @param job_t calling object
66 * @returns SUCCESS if succeeded, FAILED otherwise
68 status_t (*destroy
) (job_t
*job
);
72 * @brief Creates a job of specific type
74 * @param type type of the job
75 * @param assigned_data value to assign to the job
77 * @return job_t job object
79 job_t
*job_create(job_type_t type
, void *assigned_data
);
84 typedef struct job_queue_s job_queue_t
;
89 * @brief Returns number of jobs in queue
91 * @param job_queue_t calling object
92 * @param count integer pointer to store the job count in
93 * @returns SUCCESS if succeeded, FAILED otherwise
95 status_t (*get_count
) (job_queue_t
*job_queue
, int *count
);
98 * @brief Get the next job from the queue
100 * If the queue is empty, this function blocks until job can be returned.
102 * After using, the returned job has to get destroyed.
104 * @param job_queue_t calling object
105 * @param job pointer to a job pointer where to job is returned to
106 * @returns SUCCESS if succeeded, FAILED otherwise
108 status_t (*get
) (job_queue_t
*job_queue
, job_t
**job
);
111 * @brief Adds a job to the queue
113 * This function is non blocking
115 * @param job_queue_t calling object
116 * @param job job to add to the queue (job is not copied)
117 * @returns SUCCESS if succeeded, FAILED otherwise
119 status_t (*add
) (job_queue_t
*job_queue
, job_t
*job
);
122 * @brief Destroys a job_queue object
124 * @warning Has only to be called if no other thread is accessing the queue
126 * @param job_queue_t calling object
127 * @returns SUCCESS if succeeded, FAILED otherwise
129 status_t (*destroy
) (job_queue_t
*job_queue
);
133 * @brief Creates a job_queue
135 * @return job_queue_t empty job_queue
137 job_queue_t
*job_queue_create();
138 #endif /*JOB_QUEUE_H_*/