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
24 #ifndef EVENT_QUEUE_H_
25 #define EVENT_QUEUE_H_
27 typedef struct event_queue_t event_queue_t
;
32 #include <queues/jobs/job.h>
35 * @brief Event-Queue used to store timed events.
37 * Added events are sorted. The get method blocks until
38 * the time is elapsed to process the next event. The get
39 * method is called from the scheduler_t thread, which
40 * will add the jobs to to job_queue_t for further processing.
42 * Although the event-queue is based on a linked_list_t
43 * all access functions are thread-save implemented.
46 * - event_queue_create()
50 struct event_queue_t
{
53 * @brief Returns number of events in queue.
55 * @param event_queue calling object
56 * @return number of events in queue
58 int (*get_count
) (event_queue_t
*event_queue
);
61 * @brief Get the next job from the event-queue.
63 * If no event is pending, this function blocks until a job can be returned.
65 * @param event_queue calling object
66 * @param[out] job pointer to a job pointer where to job is returned to
69 job_t
*(*get
) (event_queue_t
*event_queue
);
72 * @brief Adds a event to the queue, using a relative time.
74 * This function is non blocking and adds a job_t at a specific time to the list.
75 * The specific job object has to get destroyed by the thread which
78 * @param event_queue calling object
79 * @param[in] job job to add to the queue (job is not copied)
80 * @param[in] time relative time, when the event has to get fired
82 void (*add_relative
) (event_queue_t
*event_queue
, job_t
*job
, u_int32_t ms
);
85 * @brief Adds a event to the queue, using an absolute time.
87 * This function is non blocking and adds a job_t at a specific time to the list.
88 * The specific job object has to get destroyed by the thread which
91 * @param event_queue calling object
92 * @param[in] job job to add to the queue (job is not copied)
93 * @param[in] time absolute time, when the event has to get fired
95 void (*add_absolute
) (event_queue_t
*event_queue
, job_t
*job
, timeval_t time
);
98 * @brief Destroys a event_queue object.
100 * @warning The caller of this function has to make sure
101 * that no thread is going to add or get an event from the event_queue
102 * after calling this function.
104 * @param event_queue calling object
106 void (*destroy
) (event_queue_t
*event_queue
);
110 * @brief Creates an empty event_queue.
112 * @returns event_queue_t object
116 event_queue_t
*event_queue_create(void);
118 #endif /*EVENT_QUEUE_H_*/