37 ret = pthread_mutex_init(&this->
queueLock,
nullptr);
43 (void) pthread_mutex_destroy(&this->
queueLock);
61 if (
nullptr != queueHandle) {
63 queueHandle =
nullptr;
68 if (
nullptr == queueHandle) {
71 if( !queueHandle->
create(depth, msgSize) ) {
76 #if FW_QUEUE_REGISTRATION
77 if (this->s_queueRegistry) {
78 this->s_queueRegistry->regQueue(
this);
88 if (
nullptr != queueHandle) {
98 pthread_mutex_t* queueLock = &queueHandle->
queueLock;
105 ret = pthread_mutex_lock(queueLock);
110 bool pushSucceeded = queue->
push(buffer, size, priority);
124 ret = pthread_mutex_unlock(queueLock);
136 pthread_cond_t* queueNotFull = &queueHandle->
queueNotFull;
137 pthread_mutex_t* queueLock = &queueHandle->
queueLock;
143 ret = pthread_mutex_lock(queueLock);
148 while( queue->
isFull() ) {
154 bool pushSucceeded = queue->
push(buffer, size, priority);
164 ret = pthread_cond_signal(queueNotEmpty);
168 ret = pthread_mutex_unlock(queueLock);
182 if (
nullptr == queueHandle) {
186 if (
nullptr == buffer) {
204 pthread_mutex_t* queueLock = &queueHandle->
queueLock;
205 pthread_cond_t* queueNotFull = &queueHandle->
queueNotFull;
215 ret = pthread_mutex_lock(queueLock);
220 bool popSucceeded = queue->
pop(buffer, size, pri);
238 else if( size == 0 ) {
249 ret = pthread_mutex_unlock(queueLock);
261 pthread_cond_t* queueNotFull = &queueHandle->
queueNotFull;
262 pthread_mutex_t* queueLock = &queueHandle->
queueLock;
272 ret = pthread_mutex_lock(queueLock);
283 bool popSucceeded = queue->
pop(buffer, size, pri);
310 ret = pthread_mutex_unlock(queueLock);
326 if (
nullptr == queueHandle) {
345 if (
nullptr == queueHandle) {
354 if (
nullptr == queueHandle) {
363 if (
nullptr == queueHandle) {
372 if (
nullptr == queueHandle) {
PlatformPointerCastType POINTER_CAST
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
A generic buffer queue data structure.
bool create(NATIVE_UINT_TYPE depth, NATIVE_UINT_TYPE msgSize)
BufferQueue creation.
NATIVE_UINT_TYPE getCount()
Get the current number of items on the queue.
NATIVE_UINT_TYPE getMsgSize()
Get the maximum message size.
bool pop(U8 *buffer, NATIVE_UINT_TYPE &size, NATIVE_INT_TYPE &priority)
pop an item off the queue
NATIVE_UINT_TYPE getDepth()
Get the queue depths.
bool isEmpty()
check if the queue is empty
bool push(const U8 *buffer, NATIVE_UINT_TYPE size, NATIVE_INT_TYPE priority)
push an item onto the queue
bool isFull()
check if the queue is full
NATIVE_UINT_TYPE getMaxCount()
Get the maximum number of items seen on the queue.
NATIVE_INT_TYPE getQueueSize() const
get the queue depth (maximum number of messages queue can hold)
NATIVE_INT_TYPE getMsgSize() const
get the message size (maximum message size queue can hold)
QueueStatus create(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
NATIVE_INT_TYPE getNumMsgs() const
get the number of messages in the queue
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
NATIVE_INT_TYPE getMaxMsgs() const
get the maximum number of messages (high watermark)
pthread_cond_t queueNotEmpty
bool create(NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
pthread_mutex_t queueLock
pthread_cond_t queueNotFull
@ QUEUE_SIZE_MISMATCH
attempted to send or receive with buffer too large, too small
@ QUEUE_UNINITIALIZED
Queue wasn't initialized successfully.
@ QUEUE_NO_MORE_MSGS
If non-blocking, all the messages have been drained.
@ QUEUE_EMPTY_BUFFER
supplied buffer is empty
@ QUEUE_OK
message sent/received okay
@ QUEUE_FULL
queue was full when attempting to send a message
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
POINTER_CAST m_handle
handle for implementation specific queue
Queue::QueueStatus sendNonBlockIPCStub(QueueHandle *queueHandle, const U8 *buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority)
Queue::QueueStatus receiveNonBlockIPCStub(QueueHandle *queueHandle, U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority)
Queue::QueueStatus receiveBlockIPCStub(QueueHandle *queueHandle, U8 *buffer, NATIVE_INT_TYPE capacity, NATIVE_INT_TYPE &actualSize, NATIVE_INT_TYPE &priority)
Queue::QueueStatus sendBlockIPCStub(QueueHandle *queueHandle, const U8 *buffer, NATIVE_INT_TYPE size, NATIVE_INT_TYPE priority)