00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: apt_cyclic_queue.h 1708 2010-05-24 17:03:25Z achaloyan $ 00017 */ 00018 00019 #ifndef APT_CYCLIC_QUEUE_H 00020 #define APT_CYCLIC_QUEUE_H 00021 00022 /** 00023 * @file apt_cyclic_queue.h 00024 * @brief Cyclic FIFO Queue of Opaque void* Objects 00025 */ 00026 00027 #include "apt.h" 00028 00029 APT_BEGIN_EXTERN_C 00030 00031 /** Default size (number of elements) of cyclic queue */ 00032 #define CYCLIC_QUEUE_DEFAULT_SIZE 100 00033 00034 /** Opaque cyclic queue declaration */ 00035 typedef struct apt_cyclic_queue_t apt_cyclic_queue_t; 00036 00037 /** 00038 * Create cyclic queue. 00039 * @param size the initial size of the queue 00040 * @return the created queue 00041 */ 00042 APT_DECLARE(apt_cyclic_queue_t*) apt_cyclic_queue_create(apr_size_t size); 00043 00044 /** 00045 * Destroy cyclic queue. 00046 * @param queue the queue to destroy 00047 */ 00048 APT_DECLARE(void) apt_cyclic_queue_destroy(apt_cyclic_queue_t *queue); 00049 00050 /** 00051 * Push object to the queue. 00052 * @param queue the queue to push object to 00053 * @param obj the object to push 00054 */ 00055 APT_DECLARE(apt_bool_t) apt_cyclic_queue_push(apt_cyclic_queue_t *queue, void *obj); 00056 00057 /** 00058 * Pop object from the queue. 00059 * @param queue the queue to pop message from 00060 */ 00061 APT_DECLARE(void*) apt_cyclic_queue_pop(apt_cyclic_queue_t *queue); 00062 00063 /** 00064 * Clear the queue (remove all the elements from the queue). 00065 * @param queue the queue to clear 00066 */ 00067 APT_DECLARE(void) apt_cyclic_queue_clear(apt_cyclic_queue_t *queue); 00068 00069 /** 00070 * Query whether the queue is empty. 00071 * @param queue the queue to query 00072 * @return TRUE if empty, otherwise FALSE 00073 */ 00074 APT_DECLARE(apt_bool_t) apt_cyclic_queue_is_empty(const apt_cyclic_queue_t *queue); 00075 00076 00077 APT_END_EXTERN_C 00078 00079 #endif /* APT_CYCLIC_QUEUE_H */