2
* @file geis_event_queue.h
3
* @brief internal Geis event queue public interface
5
* Copyright 2010 Canonical Ltd.
7
* This library is free software; you can redistribute it and/or modify it under
8
* the terms of the GNU Lesser General Public License as published by the Free
9
* Software Foundation; either version 3 of the License, or (at your option) any
12
* This library is distributed in the hope that it will be useful, but WITHOUT
13
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this program; if not, write to the Free Software Foundation, Inc.,
19
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef GEIS_EVENT_QUEUE_H_
22
#define GEIS_EVENT_QUEUE_H_
24
#include <geis/geis.h>
28
* A container for event_queues.
30
* This is a simple FIFO container for opaque GeisEvent objetcs.
32
* This container does not asssume ownership of the contained GeisEvents.
33
* Someone creates the events and pushes them into the queue, and someone pulls
34
* the events off the queue and does something with them.
36
* The current implementation uses a pooled caching strategy for dynamic
37
* allocations to minimize overhead due to high-turnover usage.
39
typedef struct _GeisEventQueue *GeisEventQueue;
43
* Creates a new Geis Event queue.
45
GeisEventQueue geis_event_queue_new();
48
* Destroys a Geis Event queue.
50
* @param[in] queue The event queue.
52
* This function empties the queue and destroys any GeisEvents malingering
53
* therein, then destroys the queue itself.
55
void geis_event_queue_delete(GeisEventQueue queue);
58
* Pushes a new event onto the back of the event queue.
60
* @param[in] queue The event queue.
62
* @retval GEIS_STATUS_SUCCESS Normal successful completion.
64
* @retval GEIS_STATUS_UNKNOWN_ERROR Something bad happened.
66
GeisStatus geis_event_queue_enqueue(GeisEventQueue queue, GeisEvent event);
69
* Indicates if an event queue is empty.
71
* @param[in] queue The event queue.
73
* @returns GEIS_TRUE if the queue contains no events, GEIS_FALSE otherwise.
75
GeisBoolean geis_event_queue_is_empty(GeisEventQueue queue);
78
* Pops the event off the front of the queue.
80
* @param[in] queue The event queue.
82
* @returns the next GeisEvent or NULL of the queue is empty.
84
GeisEvent geis_event_queue_dequeue(GeisEventQueue queue);
87
* Prototype for GEIS event matching predicate functions.
89
typedef GeisBoolean (*GeisEventMatch)(GeisEvent event, void *context);
92
* Removes events from a queue of they match a condition.
94
* @param[in] queue The event queue.
95
* @param[in] matching A unary predicate function to indicate the events to be
97
* @param[in] context An application-specific context value to be passed to
98
* the matching function.
100
void geis_event_queue_remove_if(GeisEventQueue queue,
101
GeisEventMatch matching,
104
#endif /* GEIS_EVENT_QUEUE_H_ */