15 FwSizeType index = this->m_indices[this->m_startIndex % this->m_depth];
16 this->m_startIndex = (this->m_startIndex + 1) % this->m_depth;
20void PriorityQueueHandle ::return_index(
FwSizeType index) {
21 this->m_indices[this->m_stopIndex % this->m_depth] = index;
22 this->m_stopIndex = (this->m_stopIndex + 1) % this->m_depth;
30 ::memcpy(this->m_data + offset, data, size);
31 this->m_sizes[index] = size;
38 ::memcpy(destination, this->m_data + offset, size);
55 if (indices ==
nullptr) {
60 if (sizes ==
nullptr) {
65 U8* data =
new (std::nothrow)
U8[depth * messageSize];
66 if (data ==
nullptr) {
uint8_t U8
8-bit unsigned integer
#define FW_MAX(a, b)
MAX macro.
PlatformSizeType FwSizeType
PlatformQueuePriorityType FwQueuePriorityType
void notify() override
notify a single waiter on this condition variable
void wait(Os::Mutex &mutex) override
wait on a condition variable
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue
virtual ~PriorityQueue()
default queue destructor
PriorityQueueHandle m_handle
Status create(const Fw::StringBase &name, FwSizeType depth, FwSizeType messageSize) override
create queue storage
FwSizeType getMessagesAvailable() const override
get number of messages available
FwSizeType getMessageHighWaterMark() const override
get maximum messages stored at any given time
QueueHandle * getHandle() override
return the underlying queue handle (implementation specific)
QueueHandle parent class.
@ NONBLOCKING
Message will return with status when space is unavailable.
Status
status returned from the queue send function
@ EMPTY
If non-blocking, all the messages have been drained.
@ FULL
queue was full when attempting to send a message
@ OP_OK
message sent/received okay
@ SIZE_MISMATCH
attempted to send or receive with buffer too large, too small
@ UNKNOWN_ERROR
Unexpected error; can't match with returns.
locks a mutex within the current scope
FwSizeType getSize() const
Get the current number of elements on the heap.
bool isFull()
Is the heap full?
bool isEmpty()
Is the heap empty?
bool pop(FwQueuePriorityType &value, FwSizeType &id)
Pop an item from the heap.
bool create(FwSizeType capacity)
MaxHeap creation.
bool push(FwQueuePriorityType value, FwSizeType id)
Push an item onto the heap.
Os::Mutex m_data_lock
Lock against data manipulation.
void store_data(FwSizeType index, const U8 *source, FwSizeType size)
store data into a set index in the data store
FwSizeType m_startIndex
Start index of the circular data structure.
void load_data(FwSizeType index, U8 *destination, FwSizeType capacity)
load data from a set index in the data store
void return_index(FwSizeType index)
return index to the circular data structure
FwSizeType * m_sizes
Size store for each method.
FwSizeType m_maxSize
Maximum size allowed of a message.
FwSizeType find_index()
find an available index to store data from the list
Types::MaxHeap m_heap
MaxHeap data store for tracking priority.
FwSizeType * m_indices
List of indices into data.
Os::ConditionVariable m_empty
Queue empty condition variable to support blocking.
FwSizeType m_stopIndex
End index of the circular data structure.
U8 * m_data
Pointer to data allocation.
FwSizeType m_depth
Depth of the queue.
FwSizeType m_highMark
Message count high water mark.
Os::ConditionVariable m_full
Queue full condition variable to support blocking.