172a82af4SMatthias Ringwald /* 272a82af4SMatthias Ringwald * Copyright (C) 2019 BlueKitchen GmbH 372a82af4SMatthias Ringwald * 472a82af4SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 572a82af4SMatthias Ringwald * modification, are permitted provided that the following conditions 672a82af4SMatthias Ringwald * are met: 772a82af4SMatthias Ringwald * 872a82af4SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 972a82af4SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 1072a82af4SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 1172a82af4SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 1272a82af4SMatthias Ringwald * documentation and/or other materials provided with the distribution. 1372a82af4SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 1472a82af4SMatthias Ringwald * contributors may be used to endorse or promote products derived 1572a82af4SMatthias Ringwald * from this software without specific prior written permission. 1672a82af4SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 1772a82af4SMatthias Ringwald * personal benefit and not for any commercial purpose or for 1872a82af4SMatthias Ringwald * monetary gain. 1972a82af4SMatthias Ringwald * 2072a82af4SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 2172a82af4SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2272a82af4SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 2572a82af4SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2672a82af4SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 2772a82af4SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 2872a82af4SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2972a82af4SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 3072a82af4SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3172a82af4SMatthias Ringwald * SUCH DAMAGE. 3272a82af4SMatthias Ringwald * 3372a82af4SMatthias Ringwald * Please inquire about commercial licensing options at 3472a82af4SMatthias Ringwald * [email protected] 3572a82af4SMatthias Ringwald * 3672a82af4SMatthias Ringwald */ 3772a82af4SMatthias Ringwald 38fe5a6c4eSMilanka Ringwald /** 39fe5a6c4eSMilanka Ringwald * @title Linked Queue 40fe5a6c4eSMilanka Ringwald * 4172a82af4SMatthias Ringwald */ 4272a82af4SMatthias Ringwald 4372a82af4SMatthias Ringwald #ifndef BTSTACK_LINKED_QUEUE_H 4472a82af4SMatthias Ringwald #define BTSTACK_LINKED_QUEUE_H 4572a82af4SMatthias Ringwald 4672a82af4SMatthias Ringwald #include "btstack_bool.h" 4772a82af4SMatthias Ringwald #include "btstack_linked_list.h" 4872a82af4SMatthias Ringwald 4972a82af4SMatthias Ringwald #if defined __cplusplus 5072a82af4SMatthias Ringwald extern "C" { 5172a82af4SMatthias Ringwald #endif 5272a82af4SMatthias Ringwald 5372a82af4SMatthias Ringwald /* API_START */ 5472a82af4SMatthias Ringwald 5572a82af4SMatthias Ringwald typedef struct { 5672a82af4SMatthias Ringwald btstack_linked_item_t * head; 5772a82af4SMatthias Ringwald btstack_linked_item_t * tail; 5872a82af4SMatthias Ringwald } btstack_linked_queue_t; 5972a82af4SMatthias Ringwald 6072a82af4SMatthias Ringwald /** 6172a82af4SMatthias Ringwald * @brief Tests if queue is empty 6272a82af4SMatthias Ringwald * @return true if emtpy 6372a82af4SMatthias Ringwald */ 6472a82af4SMatthias Ringwald bool btstack_linked_queue_empty(btstack_linked_queue_t * queue); 6572a82af4SMatthias Ringwald 6672a82af4SMatthias Ringwald /** 6772a82af4SMatthias Ringwald * @brief Append item to queue 6872a82af4SMatthias Ringwald * @param queue 6972a82af4SMatthias Ringwald * @param item 7072a82af4SMatthias Ringwald */ 7172a82af4SMatthias Ringwald void btstack_linked_queue_enqueue(btstack_linked_queue_t * queue, btstack_linked_item_t * item); 7272a82af4SMatthias Ringwald 7372a82af4SMatthias Ringwald /** 7472a82af4SMatthias Ringwald * @brief Pop next item from queue 7572a82af4SMatthias Ringwald * @param queue 7672a82af4SMatthias Ringwald * @return item or NULL if queue empty 7772a82af4SMatthias Ringwald */ 7872a82af4SMatthias Ringwald btstack_linked_item_t * btstack_linked_queue_dequeue(btstack_linked_queue_t * queue); 7972a82af4SMatthias Ringwald 8072a82af4SMatthias Ringwald /** 8172a82af4SMatthias Ringwald * @brief Get first item from queue 8272a82af4SMatthias Ringwald * @param queue 8372a82af4SMatthias Ringwald * @return item or NULL if queue empty 8472a82af4SMatthias Ringwald */ 8572a82af4SMatthias Ringwald btstack_linked_item_t * btstack_linked_queue_first(btstack_linked_queue_t * queue); 8672a82af4SMatthias Ringwald 8772a82af4SMatthias Ringwald /* API_END */ 8872a82af4SMatthias Ringwald 8972a82af4SMatthias Ringwald #if defined __cplusplus 9072a82af4SMatthias Ringwald } 9172a82af4SMatthias Ringwald #endif 9272a82af4SMatthias Ringwald 9372a82af4SMatthias Ringwald #endif // BTSTACK_LINKED_QUEUE_H 94