Mistake on this page?
Report an issue in GitHub or email us
wsf_queue.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file wsf_queue.h
4  *
5  * \brief General purpose queue service.
6  *
7  * Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef WSF_QUEUE_H
25 #define WSF_QUEUE_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /*! \addtogroup WSF_QUEUE_API
32  * \{ */
33 
34 /**************************************************************************************************
35  Macros
36 **************************************************************************************************/
37 
38 /*! \brief Initialize a queue */
39 #define WSF_QUEUE_INIT(pQueue) {(pQueue)->pHead = NULL; (pQueue)->pTail = NULL;}
40 
41 /**************************************************************************************************
42  Data Types
43 **************************************************************************************************/
44 
45 /*! \brief Queue structure */
46 typedef struct
47 {
48  void *pHead; /*!< \brief head of queue */
49  void *pTail; /*!< \brief tail of queue */
50 } wsfQueue_t;
51 
52 /**************************************************************************************************
53  Function Declarations
54 **************************************************************************************************/
55 
56 /*************************************************************************************************/
57 /*!
58  * \brief Enqueue an element to the tail of a queue.
59  *
60  * \param pQueue Pointer to queue.
61  * \param pElem Pointer to element.
62  */
63 /*************************************************************************************************/
64 void WsfQueueEnq(wsfQueue_t *pQueue, void *pElem);
65 
66 /*************************************************************************************************/
67 /*!
68  * \brief Dequeue an element from the head of a queue.
69  *
70  * \param pQueue Pointer to queue.
71  *
72  * \return Pointer to element that has been dequeued or NULL if queue is empty.
73  */
74 /*************************************************************************************************/
75 void *WsfQueueDeq(wsfQueue_t *pQueue);
76 
77 /*************************************************************************************************/
78 /*!
79  * \brief Push an element to the head of a queue.
80  *
81  * \param pQueue Pointer to queue.
82  * \param pElem Pointer to element.
83  */
84 /*************************************************************************************************/
85 void WsfQueuePush(wsfQueue_t *pQueue, void *pElem);
86 
87 /*************************************************************************************************/
88 /*!
89  * \brief Insert an element into a queue. This function is typically used when iterating
90  * over a queue.
91  *
92  * \param pQueue Pointer to queue.
93  * \param pElem Pointer to element to be inserted.
94  * \param pPrev Pointer to previous element in the queue before element to be inserted.
95  * Note: set pPrev to NULL if pElem is first element in queue.
96  * \return None.
97  */
98 /*************************************************************************************************/
99 void WsfQueueInsert(wsfQueue_t *pQueue, void *pElem, void *pPrev);
100 
101 /*************************************************************************************************/
102 /*!
103  * \brief Remove an element from a queue. This function is typically used when iterating
104  * over a queue.
105  *
106  * \param pQueue Pointer to queue.
107  * \param pElem Pointer to element to be removed.
108  * \param pPrev Pointer to previous element in the queue before element to be removed.
109  */
110 /*************************************************************************************************/
111 void WsfQueueRemove(wsfQueue_t *pQueue, void *pElem, void *pPrev);
112 
113 /*************************************************************************************************/
114 /*!
115  * \brief Count the number of elements in a queue.
116  *
117  * \param pQueue Pointer to queue.
118  *
119  * \return Number of elements in queue.
120  */
121 /*************************************************************************************************/
122 uint16_t WsfQueueCount(wsfQueue_t *pQueue);
123 
124 /*************************************************************************************************/
125 /*!
126  * \brief Return TRUE if queue is empty.
127  *
128  * \param pQueue Pointer to queue.
129  *
130  * \return TRUE if queue is empty, FALSE otherwise.
131  */
132 /*************************************************************************************************/
133 bool_t WsfQueueEmpty(wsfQueue_t *pQueue);
134 
135 /*************************************************************************************************/
136 /*!
137  * \brief Check for a queue depth of 1 element.
138  *
139  * \param pQueue Queue.
140  *
141  * \return TRUE if Queue only has 1 element, FALSE otherwise.
142  */
143 /*************************************************************************************************/
144 bool_t WsfIsQueueDepthOne(wsfQueue_t *pQueue);
145 
146 /*! \} */ /* WSF_QUEUE_API */
147 
148 #ifdef __cplusplus
149 };
150 #endif
151 
152 #endif /* WSF_QUEUE_H */
uint16_t WsfQueueCount(wsfQueue_t *pQueue)
Count the number of elements in a queue.
void * WsfQueueDeq(wsfQueue_t *pQueue)
Dequeue an element from the head of a queue.
bool_t WsfQueueEmpty(wsfQueue_t *pQueue)
Return TRUE if queue is empty.
void WsfQueuePush(wsfQueue_t *pQueue, void *pElem)
Push an element to the head of a queue.
Queue structure.
Definition: wsf_queue.h:46
void WsfQueueInsert(wsfQueue_t *pQueue, void *pElem, void *pPrev)
Insert an element into a queue. This function is typically used when iterating over a queue...
void * pHead
head of queue
Definition: wsf_queue.h:48
bool_t WsfIsQueueDepthOne(wsfQueue_t *pQueue)
Check for a queue depth of 1 element.
void WsfQueueEnq(wsfQueue_t *pQueue, void *pElem)
Enqueue an element to the tail of a queue.
void * pTail
tail of queue
Definition: wsf_queue.h:49
void WsfQueueRemove(wsfQueue_t *pQueue, void *pElem, void *pPrev)
Remove an element from a queue. This function is typically used when iterating over a queue...
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.