Maxim Integrated / MaximBLE

Dependents:   BLE_Thermometer MAXWSNENV_demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers wsf_queue.h Source File

wsf_queue.h

Go to the documentation of this file.
00001 /*************************************************************************************************/
00002 /*!
00003  *  \file   wsf_queue.h
00004  *        
00005  *  \brief  General purpose queue service.
00006  *
00007  *          $Date: 2011-10-14 21:35:03 -0700 (Fri, 14 Oct 2011) $
00008  *          $Revision: 191 $
00009  *  
00010  *  Copyright (c) 2009-2016 ARM Limited. All rights reserved.
00011  *
00012  *  SPDX-License-Identifier: LicenseRef-PBL
00013  *
00014  *  Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
00015  *  this file except in compliance with the License.  You may obtain a copy of the License at
00016  *
00017  *  https://www.mbed.com/licenses/PBL-1.0
00018  *
00019  *  See the License for the specific language governing permissions and limitations under the License.
00020  */
00021 /*************************************************************************************************/
00022 #ifndef WSF_QUEUE_H
00023 #define WSF_QUEUE_H
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /**************************************************************************************************
00030   Macros
00031 **************************************************************************************************/
00032 
00033 /*! Initialize a queue */
00034 #define WSF_QUEUE_INIT(pQueue)          {(pQueue)->pHead = NULL; (pQueue)->pTail = NULL;}
00035 
00036 /**************************************************************************************************
00037   Data Types
00038 **************************************************************************************************/
00039 
00040 /*! Queue structure */
00041 typedef struct
00042 {
00043   void      *pHead;         /*! head of queue */
00044   void      *pTail ;         /*! tail of queue */
00045 } wsfQueue_t ;
00046 
00047 /**************************************************************************************************
00048   Function Declarations
00049 **************************************************************************************************/
00050 
00051 /*************************************************************************************************/
00052 /*!
00053  *  \fn     WsfQueueEnq
00054  *        
00055  *  \brief  Enqueue an element to the tail of a queue.
00056  *
00057  *  \param  pQueue    Pointer to queue.
00058  *  \param  pElem     Pointer to element.
00059  *
00060  *  \return None.
00061  */
00062 /*************************************************************************************************/
00063 void WsfQueueEnq(wsfQueue_t  *pQueue, void *pElem);
00064 
00065 /*************************************************************************************************/
00066 /*!
00067  *  \fn     WsfQueueDeq
00068  *        
00069  *  \brief  Dequeue an element from the head of a queue.
00070  *
00071  *  \param  pQueue    Pointer to queue.
00072  *
00073  *  \return Pointer to element that has been dequeued or NULL if queue is empty.
00074  */
00075 /*************************************************************************************************/
00076 void *WsfQueueDeq(wsfQueue_t  *pQueue);
00077 
00078 /*************************************************************************************************/
00079 /*!
00080  *  \fn     WsfQueuePush
00081  *        
00082  *  \brief  Push an element to the head of a queue.
00083  *
00084  *  \param  pQueue    Pointer to queue.
00085  *  \param  pElem     Pointer to element.
00086  *
00087  *  \return None.
00088  */
00089 /*************************************************************************************************/
00090 void WsfQueuePush(wsfQueue_t  *pQueue, void *pElem);
00091 
00092 /*************************************************************************************************/
00093 /*!
00094  *  \fn     WsfQueueInsert
00095  *        
00096  *  \brief  Insert an element into a queue.  This function is typically used when iterating
00097  *          over a queue.
00098  *
00099  *  \param  pQueue    Pointer to queue.
00100  *  \param  pElem     Pointer to element to be inserted.
00101  *  \param  pPrev     Pointer to previous element in the queue before element to be inserted.
00102  *                    Note:  set pPrev to NULL if pElem is first element in queue.
00103  *  \return None.
00104  */
00105 /*************************************************************************************************/
00106 void WsfQueueInsert(wsfQueue_t  *pQueue, void *pElem, void *pPrev);
00107 
00108 /*************************************************************************************************/
00109 /*!
00110  *  \fn     WsfQueueRemove
00111  *        
00112  *  \brief  Remove an element from a queue.  This function is typically used when iterating
00113  *          over a queue.
00114  *
00115  *  \param  pQueue    Pointer to queue.
00116  *  \param  pElem     Pointer to element to be removed.
00117  *  \param  pPrev     Pointer to previous element in the queue before element to be removed.
00118  *
00119  *  \return None.
00120  */
00121 /*************************************************************************************************/
00122 void WsfQueueRemove(wsfQueue_t  *pQueue, void *pElem, void *pPrev);
00123 
00124 /*************************************************************************************************/
00125 /*!
00126  *  \fn     WsfQueueCount
00127  *        
00128  *  \brief  Count the number of elements in a queue.
00129  *
00130  *  \param  pQueue    Pointer to queue.
00131  *
00132  *  \return Number of elements in queue.
00133  */
00134 /*************************************************************************************************/
00135 uint16_t WsfQueueCount(wsfQueue_t  *pQueue);
00136 
00137 /*************************************************************************************************/
00138 /*!
00139  *  \fn     WsfQueueEmpty
00140  *        
00141  *  \brief  Return TRUE if queue is empty.
00142  *
00143  *  \param  pQueue    Pointer to queue.
00144  *
00145  *  \return TRUE if queue is empty, FALSE otherwise.
00146  */
00147 /*************************************************************************************************/
00148 bool_t WsfQueueEmpty(wsfQueue_t  *pQueue);
00149 
00150 
00151 #ifdef __cplusplus
00152 };
00153 #endif
00154 
00155 #endif /* WSF_QUEUE_H */