1*72a82af4SMatthias Ringwald /* 2*72a82af4SMatthias Ringwald * Copyright (C) 2019 BlueKitchen GmbH 3*72a82af4SMatthias Ringwald * 4*72a82af4SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5*72a82af4SMatthias Ringwald * modification, are permitted provided that the following conditions 6*72a82af4SMatthias Ringwald * are met: 7*72a82af4SMatthias Ringwald * 8*72a82af4SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9*72a82af4SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10*72a82af4SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11*72a82af4SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12*72a82af4SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13*72a82af4SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14*72a82af4SMatthias Ringwald * contributors may be used to endorse or promote products derived 15*72a82af4SMatthias Ringwald * from this software without specific prior written permission. 16*72a82af4SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17*72a82af4SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18*72a82af4SMatthias Ringwald * monetary gain. 19*72a82af4SMatthias Ringwald * 20*72a82af4SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21*72a82af4SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*72a82af4SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*72a82af4SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24*72a82af4SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25*72a82af4SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26*72a82af4SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27*72a82af4SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28*72a82af4SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29*72a82af4SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30*72a82af4SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*72a82af4SMatthias Ringwald * SUCH DAMAGE. 32*72a82af4SMatthias Ringwald * 33*72a82af4SMatthias Ringwald * Please inquire about commercial licensing options at 34*72a82af4SMatthias Ringwald * [email protected] 35*72a82af4SMatthias Ringwald * 36*72a82af4SMatthias Ringwald */ 37*72a82af4SMatthias Ringwald 38*72a82af4SMatthias Ringwald /* 39*72a82af4SMatthias Ringwald * btstack_linked_queue.h 40*72a82af4SMatthias Ringwald */ 41*72a82af4SMatthias Ringwald 42*72a82af4SMatthias Ringwald #ifndef BTSTACK_LINKED_QUEUE_H 43*72a82af4SMatthias Ringwald #define BTSTACK_LINKED_QUEUE_H 44*72a82af4SMatthias Ringwald 45*72a82af4SMatthias Ringwald #include "btstack_bool.h" 46*72a82af4SMatthias Ringwald #include "btstack_linked_list.h" 47*72a82af4SMatthias Ringwald 48*72a82af4SMatthias Ringwald #if defined __cplusplus 49*72a82af4SMatthias Ringwald extern "C" { 50*72a82af4SMatthias Ringwald #endif 51*72a82af4SMatthias Ringwald 52*72a82af4SMatthias Ringwald /* API_START */ 53*72a82af4SMatthias Ringwald 54*72a82af4SMatthias Ringwald typedef struct { 55*72a82af4SMatthias Ringwald btstack_linked_item_t * head; 56*72a82af4SMatthias Ringwald btstack_linked_item_t * tail; 57*72a82af4SMatthias Ringwald } btstack_linked_queue_t; 58*72a82af4SMatthias Ringwald 59*72a82af4SMatthias Ringwald /** 60*72a82af4SMatthias Ringwald * @brief Tests if queue is empty 61*72a82af4SMatthias Ringwald * @return true if emtpy 62*72a82af4SMatthias Ringwald */ 63*72a82af4SMatthias Ringwald bool btstack_linked_queue_empty(btstack_linked_queue_t * queue); 64*72a82af4SMatthias Ringwald 65*72a82af4SMatthias Ringwald /** 66*72a82af4SMatthias Ringwald * @brief Append item to queue 67*72a82af4SMatthias Ringwald * @param queue 68*72a82af4SMatthias Ringwald * @param item 69*72a82af4SMatthias Ringwald */ 70*72a82af4SMatthias Ringwald void btstack_linked_queue_enqueue(btstack_linked_queue_t * queue, btstack_linked_item_t * item); 71*72a82af4SMatthias Ringwald 72*72a82af4SMatthias Ringwald /** 73*72a82af4SMatthias Ringwald * @brief Pop next item from queue 74*72a82af4SMatthias Ringwald * @param queue 75*72a82af4SMatthias Ringwald * @return item or NULL if queue empty 76*72a82af4SMatthias Ringwald */ 77*72a82af4SMatthias Ringwald btstack_linked_item_t * btstack_linked_queue_dequeue(btstack_linked_queue_t * queue); 78*72a82af4SMatthias Ringwald 79*72a82af4SMatthias Ringwald /** 80*72a82af4SMatthias Ringwald * @brief Get first item from queue 81*72a82af4SMatthias Ringwald * @param queue 82*72a82af4SMatthias Ringwald * @return item or NULL if queue empty 83*72a82af4SMatthias Ringwald */ 84*72a82af4SMatthias Ringwald btstack_linked_item_t * btstack_linked_queue_first(btstack_linked_queue_t * queue); 85*72a82af4SMatthias Ringwald 86*72a82af4SMatthias Ringwald /* API_END */ 87*72a82af4SMatthias Ringwald 88*72a82af4SMatthias Ringwald #if defined __cplusplus 89*72a82af4SMatthias Ringwald } 90*72a82af4SMatthias Ringwald #endif 91*72a82af4SMatthias Ringwald 92*72a82af4SMatthias Ringwald #endif // BTSTACK_LINKED_QUEUE_H 93