OS  v7.3.3
Documentation
Loading...
Searching...
No Matches
qqueues.h
1
8#ifndef QQUEUES_H
9 #define QQUEUES_H
10
11 #include "qtypes.h"
12 #include "qcritical.h"
13 #include <string.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 #ifndef Q_QUEUES
20 #define Q_QUEUES ( 1 )
21 #endif
22
53 typedef struct _qQueue_s { // skipcq: CXX-E2000
55 struct _qQueue_Private_s { // skipcq: CXX-E2000
56 qUINT8_t *head; /*< Points to the beginning of the queue storage area. */
57 qUINT8_t *tail; /*< Points to the byte at the end of the queue storage area. Once more byte is allocated than necessary to store the queue items, this is used as a marker. */
58 qUINT8_t *writer; /*< Points to the free next place in the storage area. */
59 qUINT8_t *reader; /*< Points to the last place that a queued item was read from. */
60 volatile size_t itemsWaiting; /*< The number of items currently in the queue. */
61 size_t itemsCount; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */
62 size_t itemSize; /*< The size of each items that the queue will hold. */
63 }
64 qPrivate;
66 }
68
71 #define QUEUE_SEND_TO_BACK ( 0U )
72
75 #define QUEUE_SEND_TO_FRONT ( 1U )
76
80
87 qBool_t qQueue_IsReady( const qQueue_t * const q );
88
98 qBool_t qQueue_Setup( qQueue_t * const q,
99 void* pData,
100 const size_t itemSize,
101 const size_t itemsCount );
102
108 qBool_t qQueue_Reset( qQueue_t * const q );
109
115 qBool_t qQueue_IsEmpty( const qQueue_t * const q );
116
122 size_t qQueue_Count( const qQueue_t * const q );
123
130 size_t qQueue_ItemsAvailable( const qQueue_t * const q );
131
137 qBool_t qQueue_IsFull( const qQueue_t * const q );
138
144 void* qQueue_Peek( const qQueue_t * const q );
145
153
165 void *dst );
166
180 qBool_t qQueue_Send( qQueue_t * const q,
181 void *itemToQueue,
182 const qQueue_InsertMode_t pos );
183
186 #ifdef __cplusplus
187 }
188 #endif
189
190#endif
qBool_t qQueue_IsEmpty(const qQueue_t *const q)
Returns the empty status of the Queue.
Definition qqueues.c:72
void * qQueue_Peek(const qQueue_t *const q)
Looks at the data from the front of the Queue without removing it.
Definition qqueues.c:118
qUINT8_t qQueue_InsertMode_t
A typedef to indicate the queue send mode : QUEUE_SEND_TO_BACK or QUEUE_SEND_TO_FRONT.
Definition qqueues.h:79
qBool_t qQueue_Send(qQueue_t *const q, void *itemToQueue, const qQueue_InsertMode_t pos)
Post an item to the the queue. The item is queued by copy, not by reference.
Definition qqueues.c:218
qBool_t qQueue_IsFull(const qQueue_t *const q)
Returns the full status of the Queue.
Definition qqueues.c:105
qBool_t qQueue_Receive(qQueue_t *const q, void *dst)
Receive an item from a queue (and removes it). The item is received by copy so a buffer of adequate s...
Definition qqueues.c:197
qBool_t qQueue_RemoveFront(qQueue_t *const q)
Remove the data located at the front of the Queue.
Definition qqueues.c:142
qBool_t qQueue_Setup(qQueue_t *const q, void *pData, const size_t itemSize, const size_t itemsCount)
Configures a Queue. Here, the RAM used to hold the queue data pData is statically allocated at compil...
Definition qqueues.c:32
qBool_t qQueue_IsReady(const qQueue_t *const q)
Check if the queue is already initialized by using qQueue_Setup() API.
Definition qqueues.c:19
qBool_t qQueue_Reset(qQueue_t *const q)
Resets a queue to its original empty state.
Definition qqueues.c:55
size_t qQueue_Count(const qQueue_t *const q)
Returns the number of items in the Queue.
Definition qqueues.c:83
size_t qQueue_ItemsAvailable(const qQueue_t *const q)
Returns the number of available slots to hold items inside the queue.
Definition qqueues.c:94
qUINT8_t qBool_t
A type to instantiate an OS boolean variable.
Definition qtypes.h:139
uint8_t qUINT8_t
Unsigned integer type with width of exactly 8 bits respectively.
Definition qtypes.h:44
A Queue object.
Definition qqueues.h:53