/usr/include/wombat/queue.h is in libmama-dev 2.2.2.1-11ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | /* $Id$
*
* OpenMAMA: The open middleware agnostic messaging API
* Copyright (C) 2011 NYSE Technologies, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef WOMBAT_QUEUE_H__
#define WOMBAT_QUEUE_H__
/*
* Fully thread safe queue implementation.
*/
#ifdef SEM_VALUE_MAX
#define WOMBAT_QUEUE_MAX_SIZE SEM_VALUE_MAX /* 2_147_483_647 on Linux */
#else
#define WOMBAT_QUEUE_MAX_SIZE 2147483647 /* max possible size */
#endif
#define WOMBAT_QUEUE_CHUNK_SIZE 64 /* default chunk size */
#if defined (__cplusplus)
extern "C"
{
#endif
/* Callback for dispatching events from a queue. */
typedef void (MAMACALLTYPE *wombatQueueCb)(void* data, void* closure);
typedef void* wombatQueue;
typedef enum
{
WOMBAT_QUEUE_OK = 1,
WOMBAT_QUEUE_FULL = 2,
WOMBAT_QUEUE_NOMEM = 3,
WOMBAT_QUEUE_SEM_ERR = 4,
WOMBAT_QUEUE_MTX_ERR = 5,
WOMBAT_QUEUE_INVALID_ARG = 6,
WOMBAT_QUEUE_WOULD_BLOCK = 7,
WOMBAT_QUEUE_END = 8,
WOMBAT_QUEUE_TIMEOUT = 9
} wombatQueueStatus;
/**
* Allocate a queue. The queue will not be usable until wombatQueue_create()
* is called.
*
* Size and other parameters may be set prior to calling wombatQueue_create().
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_allocate (wombatQueue *result);
/**
* Initialize the Queue. The growBySize indicates how many
* elements to allocate at a time.
*
* The max size bounds the queue to the specified size. The default is
* unbounded up to WOMBAT_QUEUE_MAX_SIZE.
*
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_create (wombatQueue queue, uint32_t maxSize, uint32_t initialSize,
uint32_t growBySize);
/**
* Destroy the Queue.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_destroy (wombatQueue queue);
/**
* Set the maximum size of the queue. WOMBAT_QUEUE_MAX_SIZE is the maximum
* queue size permitted and the default value. This value should be a multiple
* of the chunk size.
*
* If it is not the actual max size will be rounded up to a multiple of the
* chunk size.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_setMaxSize (wombatQueue queue, unsigned int value);
/**
* Get the maximum size of the queue. WOMBAT_QUEUE_MAX_SIZE is the maximum
* queue size permitted and the default value.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_getMaxSize (wombatQueue queue, unsigned int *value);
/**
* Get the number of items currently in the queue.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_getSize (wombatQueue queue, int* size);
/**
* Enqueue an event.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_enqueue (wombatQueue queue,
wombatQueueCb cb,
void* data,
void* closure);
/**
* Dequeue an item. If a non-NULL callback was specified when the item was
* enqueued the callback will be invoked. If the data argument is not NULL,
* the dispatched item will be assigned as well.
*
* This call blocks until an item is enqueued if the queue is empty.
*
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_dispatch (wombatQueue queue, void** data, void** closure);
/**
* Dequeue an item. If a non-NULL callback was specified when the item was
* enqueued the callback will be invoked. If the data argument is not NULL,
* the dispatched item will be assigned as well.
*
* If the queue is empty wait timout milliseconds before timing out and
* returning WOMBAT_QUEUE_TIMEOUT
*
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_timedDispatch (wombatQueue queue, void** data, void** closure,
uint64_t timeout);
/**
* Poll. This function deques and item if the queue is not empty otherwise it
* returns immediately with WOMBAT__WOULD_BLOCK.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_poll (wombatQueue queue, void** data, void** closure);
/**
* Cause a waiting thread to unblock without dequing an item. This is useful
* when cleaning up.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_unblock (wombatQueue queue);
/**
* Remove each item from the queue in order and invoke the supplied callback.
* This is an atomic operation.,
*
* The itemClosure is the closure, if any, specified when the item was
* enqueued. The "closure" is the closure passed to wombatQueue_flush().
*
*/
typedef void (MAMACALLTYPE *wombatQueueFlushCb)(wombatQueue queue,
void* data,
void* itemClosure,
void* closure);
COMMONExpDLL wombatQueueStatus
wombatQueue_flush (wombatQueue queue, wombatQueueFlushCb cb, void* closure);
/**
* The queue contains a single iterator. This returns the next item. If the
* iterator is at the beginning of the queue, it returns the first item.
* It returns WOMBAT_QUEUE_END and sets the data and closure to NULL if the
* iterator is at the end of the queue. In this case the iterator does not
* move.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_next (wombatQueue queue, void** data, void** closure);
/**
* The queue contains a single iterator. This returns the previous item. If the
* iterator is at the end of the queue, it returns the last item.
* It returns WOMBAT_QUEUE_END and sets the data and closure to NULL if the
* iterator is at the beginning of the queue.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_prev (wombatQueue queue, void** data, void** closure);
/**
* The queue contains a single iterator. This returns the current item. If the
* the queue is empty or the iterator is not initialized (next() not called),
* it returns WOMBAT_QUEUE_END, and does sets the data and closure to NULL.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_cur (wombatQueue queue, void** data, void** closure);
/**
* Remove the current item. If the queue is empty this method returns
* WOMBAT_QUEUE_END.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_remove (wombatQueue queue, void** data, void** closure);
/**
* Insert a new item after the current item. The iterator is not moved. If the
* queue is empty the iterator is positioned so that next() returns the newly
* inserted item.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_insertAfter (wombatQueue queue,
wombatQueueCb cb,
void* data,
void* closure);
/**
* Insert a new item before the current item. The iterator is not moved. If the
* queue is empty the iterator is positioned so that prev() returns the newly
* inserted item.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_insertBefore (wombatQueue queue,
wombatQueueCb cb,
void* data,
void* closure);
/**
* Replace the data and closure for the current node. If the iterator is not
* positioned because the queue is empty or next() has not been called,
* it will return WOMBAT_QUEUE_END.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_replace (wombatQueue queue,
wombatQueueCb cb,
void* data,
void* closure);
/**
* Position the iterator so next() will return the first element.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_begin (wombatQueue queue);
/**
* Position the iterator so prev() will return the last element.
*/
COMMONExpDLL wombatQueueStatus
wombatQueue_end (wombatQueue queue);
#if defined (__cplusplus)
}
#endif
#endif /* WOMBAT_QUEUE_H__ */
|