123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
- * applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #ifndef APR_QUEUE_H
- #define APR_QUEUE_H
- /**
- * @file apr_queue.h
- * @brief Thread Safe FIFO bounded queue
- * @note Since most implementations of the queue are backed by a condition
- * variable implementation, it isn't available on systems without threads.
- * Although condition variables are some times available without threads.
- */
- #include "apu.h"
- #include "apr_errno.h"
- #include "apr_pools.h"
- #if APR_HAS_THREADS
- #ifdef __cplusplus
- extern "C" {
- #endif /* __cplusplus */
- /**
- * @defgroup APR_Util_FIFO Thread Safe FIFO bounded queue
- * @ingroup APR_Util
- * @{
- */
- /**
- * opaque structure
- */
- typedef struct apr_queue_t apr_queue_t;
- /**
- * create a FIFO queue
- * @param queue The new queue
- * @param queue_capacity maximum size of the queue
- * @param a pool to allocate queue from
- */
- APU_DECLARE(apr_status_t) apr_queue_create(apr_queue_t **queue,
- unsigned int queue_capacity,
- apr_pool_t *a);
- /**
- * push/add a object to the queue, blocking if the queue is already full
- *
- * @param queue the queue
- * @param data the data
- * @returns APR_EINTR the blocking was interrupted (try again)
- * @returns APR_EOF the queue has been terminated
- * @returns APR_SUCCESS on a successfull push
- */
- APU_DECLARE(apr_status_t) apr_queue_push(apr_queue_t *queue, void *data);
- /**
- * pop/get an object from the queue, blocking if the queue is already empty
- *
- * @param queue the queue
- * @param data the data
- * @returns APR_EINTR the blocking was interrupted (try again)
- * @returns APR_EOF if the queue has been terminated
- * @returns APR_SUCCESS on a successfull pop
- */
- APU_DECLARE(apr_status_t) apr_queue_pop(apr_queue_t *queue, void **data);
- /**
- * pop/get an object from the queue, blocking if the queue is already empty
- *
- * @param queue the queue
- * @param data the data
- * @param timeout The amount of time in microseconds to wait. This is
- * a maximum, not a minimum. If the condition is signaled, we
- * will wake up before this time, otherwise the error APR_TIMEUP
- * is returned.
- * @returns APR_TIMEUP the request timed out
- * @returns APR_EINTR the blocking was interrupted (try again)
- * @returns APR_EOF if the queue has been terminated
- * @returns APR_SUCCESS on a successfull pop
- */
- APU_DECLARE(apr_status_t) apr_queue_pop_timeout(apr_queue_t *queue, void **data, apr_interval_time_t timeout);
- /**
- * push/add a object to the queue, returning immediatly if the queue is full
- *
- * @param queue the queue
- * @param data the data
- * @returns APR_EINTR the blocking operation was interrupted (try again)
- * @returns APR_EAGAIN the queue is full
- * @returns APR_EOF the queue has been terminated
- * @returns APR_SUCCESS on a successfull push
- */
- APU_DECLARE(apr_status_t) apr_queue_trypush(apr_queue_t *queue, void *data);
- /**
- * pop/get an object to the queue, returning immediatly if the queue is empty
- *
- * @param queue the queue
- * @param data the data
- * @returns APR_EINTR the blocking operation was interrupted (try again)
- * @returns APR_EAGAIN the queue is empty
- * @returns APR_EOF the queue has been terminated
- * @returns APR_SUCCESS on a successfull push
- */
- APU_DECLARE(apr_status_t) apr_queue_trypop(apr_queue_t *queue, void **data);
- /**
- * returns the size of the queue.
- *
- * @warning this is not threadsafe, and is intended for reporting/monitoring
- * of the queue.
- * @param queue the queue
- * @returns the size of the queue
- */
- APU_DECLARE(unsigned int) apr_queue_size(apr_queue_t *queue);
- /**
- * interrupt all the threads blocking on this queue.
- *
- * @param queue the queue
- */
- APU_DECLARE(apr_status_t) apr_queue_interrupt_all(apr_queue_t *queue);
- /**
- * terminate all queue, sendinging a interupt to all the
- * blocking threads
- *
- * @param queue the queue
- */
- APU_DECLARE(apr_status_t) apr_queue_term(apr_queue_t *queue);
- #ifdef __cplusplus
- }
- #endif
- /** @} */
- #endif /* APR_HAS_THREADS */
- #endif /* APRQUEUE_H */
|