F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Os::Generic::PriorityQueue Class Reference

generic priority queue implementation More...

#include <Os/Generic/PriorityQueue.hpp>

Inheritance diagram for Os::Generic::PriorityQueue:
Os::QueueInterface

Public Member Functions

 PriorityQueue ()=default
 default queue interface constructor More...
 
virtual ~PriorityQueue ()
 default queue destructor More...
 
 PriorityQueue (const QueueInterface &other)=delete
 copy constructor is forbidden More...
 
 PriorityQueue (const QueueInterface *other)=delete
 copy constructor is forbidden More...
 
PriorityQueueoperator= (const QueueInterface &other) override=delete
 assignment operator is forbidden More...
 
Status create (const Fw::StringBase &name, FwSizeType depth, FwSizeType messageSize) override
 create queue storage More...
 
Status send (const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
 send a message into the queue More...
 
Status receive (U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
 receive a message from the queue More...
 
FwSizeType getMessagesAvailable () const override
 get number of messages available More...
 
FwSizeType getMessageHighWaterMark () const override
 get maximum messages stored at any given time More...
 
QueueHandlegetHandle () override
 return the underlying queue handle (implementation specific) More...
 
- Public Member Functions inherited from Os::QueueInterface
 QueueInterface ()=default
 default queue interface constructor More...
 
virtual ~QueueInterface ()=default
 default queue destructor More...
 
 QueueInterface (const QueueInterface &other)=delete
 copy constructor is forbidden More...
 
 QueueInterface (const QueueInterface *other)=delete
 copy constructor is forbidden More...
 

Public Attributes

PriorityQueueHandle m_handle
 

Additional Inherited Members

- Public Types inherited from Os::QueueInterface
enum  Status {
  OP_OK, ALREADY_CREATED, EMPTY, UNINITIALIZED,
  SIZE_MISMATCH, SEND_ERROR, RECEIVE_ERROR, INVALID_PRIORITY,
  FULL, NOT_SUPPORTED, UNKNOWN_ERROR
}
 status returned from the queue send function More...
 
enum  BlockingType { BLOCKING, NONBLOCKING }
 message type More...
 
- Static Public Member Functions inherited from Os::QueueInterface
static QueueInterfacegetDelegate (QueueHandleStorage &aligned_placement_new_memory)
 provide a pointer to a queue delegate object More...
 

Detailed Description

generic priority queue implementation

Warning
This Priority Queue is not ISR safe

A generic implementation of a priority queue to support the Os::QueueInterface. This queue uses OSAL mutexes, and condition variables to provide for a task-safe blocking queue implementation. Data is stored in heap memory.

Warning
allocates memory on the heap

Definition at line 56 of file PriorityQueue.hpp.

Constructor & Destructor Documentation

◆ PriorityQueue() [1/3]

Os::Generic::PriorityQueue::PriorityQueue ( )
default

default queue interface constructor

◆ ~PriorityQueue()

Os::Generic::PriorityQueue::~PriorityQueue ( )
virtual

default queue destructor

Definition at line 41 of file PriorityQueue.cpp.

◆ PriorityQueue() [2/3]

Os::Generic::PriorityQueue::PriorityQueue ( const QueueInterface other)
delete

copy constructor is forbidden

◆ PriorityQueue() [3/3]

Os::Generic::PriorityQueue::PriorityQueue ( const QueueInterface other)
delete

copy constructor is forbidden

Member Function Documentation

◆ create()

QueueInterface::Status Os::Generic::PriorityQueue::create ( const Fw::StringBase name,
FwSizeType  depth,
FwSizeType  messageSize 
)
overridevirtual

create queue storage

Creates a queue ensuring sufficient storage to hold depth messages of messageSize size each.

Warning
allocates memory on the heap
Parameters
namename of queue
depthdepth of queue in number of messages
messageSizesize of an individual message
Returns
: status of the creation

Implements Os::QueueInterface.

Definition at line 47 of file PriorityQueue.cpp.

◆ getHandle()

QueueHandle * Os::Generic::PriorityQueue::getHandle ( )
overridevirtual

return the underlying queue handle (implementation specific)

Returns
internal task handle representation

Implements Os::QueueInterface.

Definition at line 164 of file PriorityQueue.cpp.

◆ getMessageHighWaterMark()

FwSizeType Os::Generic::PriorityQueue::getMessageHighWaterMark ( ) const
overridevirtual

get maximum messages stored at any given time

Warning
This method is not ISR safe

Returns the maximum number of messages in this queue at any given time. This is the high-water mark for this queue.

Returns
queue message high-water mark

Implements Os::QueueInterface.

Definition at line 158 of file PriorityQueue.cpp.

◆ getMessagesAvailable()

FwSizeType Os::Generic::PriorityQueue::getMessagesAvailable ( ) const
overridevirtual

get number of messages available

Returns
number of messages available

Implements Os::QueueInterface.

Definition at line 154 of file PriorityQueue.cpp.

◆ operator=()

PriorityQueue& Os::Generic::PriorityQueue::operator= ( const QueueInterface other)
overridevirtualdelete

assignment operator is forbidden

Reimplemented from Os::QueueInterface.

◆ receive()

QueueInterface::Status Os::Generic::PriorityQueue::receive ( U8 destination,
FwSizeType  capacity,
QueueInterface::BlockingType  blockType,
FwSizeType actualSize,
FwQueuePriorityType priority 
)
overridevirtual

receive a message from the queue

Receive a message from the queue, providing the message destination, capacity, priority, and blocking type. When blockType is set to BLOCKING, this call will block on queue empty. Otherwise, this will return an error status on queue empty. Actual size received and priority of message is set on success status.

Warning
It is invalid to send a null buffer
This method will block if the queue is full and blockType is set to BLOCKING
Parameters
destinationdestination for message data
capacitymaximum size of message data
blockTypeBLOCKING to wait for message or NONBLOCKING to return error when queue is empty
actualSize(output) actual size of message read
priority(output) priority of message read
Returns
: status of the send

Implements Os::QueueInterface.

Definition at line 127 of file PriorityQueue.cpp.

◆ send()

QueueInterface::Status Os::Generic::PriorityQueue::send ( const U8 buffer,
FwSizeType  size,
FwQueuePriorityType  priority,
QueueInterface::BlockingType  blockType 
)
overridevirtual

send a message into the queue

Send a message into the queue, providing the message data, size, priority, and blocking type. When blockType is set to BLOCKING, this call will block on queue full. Otherwise, this will return an error status on queue full.

Warning
It is invalid to send a null buffer
This method will block if the queue is full and blockType is set to BLOCKING
This method is not ISR safe
Parameters
buffermessage data
sizesize of message data
prioritypriority of the message
blockTypeBLOCKING to block for space or NONBLOCKING to return error when queue is full
Returns
: status of the send

Implements Os::QueueInterface.

Definition at line 97 of file PriorityQueue.cpp.

Member Data Documentation

◆ m_handle

PriorityQueueHandle Os::Generic::PriorityQueue::m_handle

Definition at line 139 of file PriorityQueue.hpp.


The documentation for this class was generated from the following files: