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
23 #ifndef EVENT_QUEUE_H_
24 #define EVENT_QUEUE_H_
29 #include <queues/jobs/job.h>
31 typedef struct event_queue_t event_queue_t
;
34 * @brief Event-Queue used to store timed events.
36 * Although the event-queue is based on a linked_list_t
37 * all access functions are thread-save implemented.
41 struct event_queue_t
{
44 * @brief Returns number of events in queue.
46 * @param event_queue calling object
47 * @return number of events in queue
49 int (*get_count
) (event_queue_t
*event_queue
);
52 * @brief Get the next job from the event-queue.
54 * If no event is pending, this function blocks until a job can be returned.
56 * @param event_queue calling object
57 * @param[out] job pointer to a job pointer where to job is returned to
60 job_t
*(*get
) (event_queue_t
*event_queue
);
63 * @brief Adds a event to the queue, using a relative time.
65 * This function is non blocking and adds a job_t at a specific time to the list.
66 * The specific job object has to get destroyed by the thread which
69 * @param event_queue calling object
70 * @param[in] job job to add to the queue (job is not copied)
71 * @param[in] time relative time, when the event has to get fired
73 void (*add_relative
) (event_queue_t
*event_queue
, job_t
*job
, u_int32_t ms
);
76 * @brief Adds a event to the queue, using an absolute time.
78 * This function is non blocking and adds a job_t at a specific time to the list.
79 * The specific job object has to get destroyed by the thread which
82 * @param event_queue calling object
83 * @param[in] job job to add to the queue (job is not copied)
84 * @param[in] absolute time time, when the event has to get fired
86 void (*add_absolute
) (event_queue_t
*event_queue
, job_t
*job
, timeval_t time
);
89 * @brief Destroys a event_queue object.
91 * @warning The caller of this function has to make sure
92 * that no thread is going to add or get an event from the event_queue
93 * after calling this function.
95 * @param event_queue calling object
96 * @returns always SUCCESS
98 void (*destroy
) (event_queue_t
*event_queue
);
102 * @brief Creates an empty event_queue
104 * @returns event_queue
108 event_queue_t
*event_queue_create();
110 #endif /*EVENT_QUEUE_H_*/