Apache Portable Runtime
Loading...
Searching...
No Matches
apr_queue.h
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef APR_QUEUE_H
18#define APR_QUEUE_H
19
20/**
21 * @file apr_queue.h
22 * @brief Thread Safe FIFO bounded queue
23 * @note Since most implementations of the queue are backed by a condition
24 * variable implementation, it isn't available on systems without threads.
25 * Although condition variables are sometimes available without threads.
26 */
27
28#include "apu.h"
29#include "apr_errno.h"
30#include "apr_pools.h"
31#include "apr_time.h"
32
33#if APR_HAS_THREADS
34
35#ifdef __cplusplus
36extern "C" {
37#endif /* __cplusplus */
38
39/**
40 * @defgroup APR_Util_FIFO Thread Safe FIFO bounded queue
41 * @ingroup APR
42 * @{
43 */
44
45/**
46 * opaque structure
47 */
48typedef struct apr_queue_t apr_queue_t;
49
50/**
51 * create a FIFO queue
52 * @param queue The new queue
53 * @param queue_capacity maximum size of the queue
54 * @param a pool to allocate queue from
55 */
57 unsigned int queue_capacity,
58 apr_pool_t *a);
59
60/**
61 * push/add an object to the queue, blocking if the queue is already full
62 *
63 * @param queue the queue
64 * @param data the data
65 * @returns APR_EINTR the blocking was interrupted (try again)
66 * @returns APR_EOF the queue has been terminated
67 * @returns APR_SUCCESS on a successful push
68 */
70
71/**
72 * pop/get an object from the queue, blocking if the queue is already empty
73 *
74 * @param queue the queue
75 * @param data the data
76 * @returns APR_EINTR the blocking was interrupted (try again)
77 * @returns APR_EOF if the queue has been terminated
78 * @returns APR_SUCCESS on a successful pop
79 */
81
82/**
83 * push/add an object to the queue, returning immediately if the queue is full
84 *
85 * @param queue the queue
86 * @param data the data
87 * @returns APR_EINTR the blocking operation was interrupted (try again)
88 * @returns APR_EAGAIN the queue is full
89 * @returns APR_EOF the queue has been terminated
90 * @returns APR_SUCCESS on a successful push
91 */
93
94/**
95 * pop/get an object from the queue, returning immediately if the queue is empty
96 *
97 * @param queue the queue
98 * @param data the data
99 * @returns APR_EINTR the blocking operation was interrupted (try again)
100 * @returns APR_EAGAIN the queue is empty
101 * @returns APR_EOF the queue has been terminated
102 * @returns APR_SUCCESS on a successful pop
103 */
105
106/**
107 * push/add an object to the queue, waiting a maximum of timeout microseconds
108 * before returning if the queue is empty
109 *
110 * @param queue the queue
111 * @param data the data
112 * @param timeout the timeout
113 * @returns APR_EINTR the blocking operation was interrupted (try again)
114 * @returns APR_EAGAIN the queue is empty and timeout is 0
115 * @returns APR_TIMEUP the queue is empty and the timeout expired
116 * @returns APR_EOF the queue has been terminated
117 * @returns APR_SUCCESS on a successful pop
118 */
120 apr_interval_time_t timeout);
121
122/**
123 * pop/get an object from the queue, waiting a maximum of timeout microseconds
124 * before returning if the queue is empty
125 *
126 * @param queue the queue
127 * @param data the data
128 * @param timeout the timeout
129 * @returns APR_EINTR the blocking operation was interrupted (try again)
130 * @returns APR_EAGAIN the queue is empty and timeout is 0
131 * @returns APR_TIMEUP the queue is empty and the timeout expired
132 * @returns APR_EOF the queue has been terminated
133 * @returns APR_SUCCESS on a successful pop
134 */
136 apr_interval_time_t timeout);
137
138/**
139 * returns the size of the queue.
140 *
141 * @warning this is not threadsafe, and is intended for reporting/monitoring
142 * of the queue.
143 * @param queue the queue
144 * @returns the size of the queue
145 */
147
148/**
149 * interrupt all the threads blocking on this queue.
150 *
151 * @param queue the queue
152 */
154
155/**
156 * terminate the queue, sending an interrupt to all the
157 * blocking threads
158 *
159 * @param queue the queue
160 */
162
163#ifdef __cplusplus
164}
165#endif
166
167/** @} */
168
169#endif /* APR_HAS_THREADS */
170
171#endif /* APRQUEUE_H */
APR Error Codes.
APR memory allocation.
APR Time Library.
apr_status_t apr_queue_trypop(apr_queue_t *queue, void **data)
apr_status_t apr_queue_push(apr_queue_t *queue, void *data)
apr_status_t apr_queue_timedpop(apr_queue_t *queue, void **data, apr_interval_time_t timeout)
apr_status_t apr_queue_timedpush(apr_queue_t *queue, void *data, apr_interval_time_t timeout)
apr_status_t apr_queue_pop(apr_queue_t *queue, void **data)
apr_status_t apr_queue_interrupt_all(apr_queue_t *queue)
struct apr_queue_t apr_queue_t
Definition apr_queue.h:48
apr_status_t apr_queue_create(apr_queue_t **queue, unsigned int queue_capacity, apr_pool_t *a)
apr_status_t apr_queue_trypush(apr_queue_t *queue, void *data)
apr_status_t apr_queue_term(apr_queue_t *queue)
unsigned int apr_queue_size(apr_queue_t *queue)
int apr_status_t
Definition apr_errno.h:44
#define APR_DECLARE(type)
Definition apr.h:523
struct apr_pool_t apr_pool_t
Definition apr_pools.h:60
apr_int64_t apr_interval_time_t
Definition apr_time.h:55