31 (void)::memcpy(this->
m_data + offset, data, static_cast<size_t>(size));
39 (void)::memcpy(destination, this->
m_data + offset, static_cast<size_t>(size));
60 void* allocation =
nullptr;
65 U8* heap_pointer =
nullptr;
70 if (allocation ==
nullptr) {
71 status = QueueInterface::Status::ALLOCATION_FAILED;
72 }
else if (size < (depth *
sizeof(
FwSizeType))) {
74 status = QueueInterface::Status::ALLOCATION_FAILED;
76 indices = Fw::arrayPlacementNew<FwSizeType>(
Fw::ByteArray(static_cast<U8*>(allocation), size), depth);
83 if (allocation ==
nullptr) {
85 status = QueueInterface::Status::ALLOCATION_FAILED;
86 }
else if (size < (depth *
sizeof(
FwSizeType))) {
89 status = QueueInterface::Status::ALLOCATION_FAILED;
91 sizes = Fw::arrayPlacementNew<FwSizeType>(
Fw::ByteArray(static_cast<U8*>(allocation), size), depth);
96 size = depth * messageSize;
97 allocation = allocator.
allocate(identifier, size,
alignof(
U8));
98 if (allocation ==
nullptr) {
101 status = QueueInterface::Status::ALLOCATION_FAILED;
102 }
else if (size < (depth * messageSize)) {
106 status = QueueInterface::Status::ALLOCATION_FAILED;
108 data =
static_cast<U8*
>(allocation);
115 if (allocation ==
nullptr) {
119 status = QueueInterface::Status::ALLOCATION_FAILED;
125 status = QueueInterface::Status::ALLOCATION_FAILED;
127 heap_pointer =
static_cast<U8*
>(allocation);
181 return QueueInterface::Status::SIZE_MISMATCH;
187 return QueueInterface::Status::FULL;
213 return QueueInterface::Status::EMPTY;
void notify() override
notify a single waiter on this condition variable
virtual void * allocate(const FwEnumStoreType identifier, FwSizeType &size, bool &recoverable, FwSizeType alignment=alignof(std::max_align_t))=0
static constexpr FwSizeType ALIGNMENT
Exposes the ALIGNMENT for pre-allocation.
FwSizeType * m_sizes
Size store for each method.
PlatformSizeType FwSizeType
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue
Status
status returned from the queue send function
FwSizeType * m_indices
List of indices into data.
U8 * m_heap_pointer
Pointer to the MaxHeap data store.
QueueHandle parent class.
bool pop(FwQueuePriorityType &value, FwSizeType &id)
Pop an item from the heap.
U8 * m_data
Pointer to data allocation.
FwSizeType m_stopIndex
End index of the circular data structure.
FwSizeType m_startIndex
Start index of the circular data structure.
FwSizeType m_maxSize
Maximum size allowed of a message.
FwSizeType m_depth
Depth of the queue.
static MemAllocatorRegistry & getInstance()
get the singleton registry
void teardownInternal()
teardown the queue
FwSizeType m_highMark
Message count high water mark.
REQUIRED: required for Os::Queue memory allocation when using queues that allocate memory...
QueueHandle * getHandle() override
return the underlying queue handle (implementation specific)
MemAllocator & getAnAllocator(const MemoryAllocation::MemoryAllocatorType type)
FwSizeType getMessageHighWaterMark() const override
get maximum messages stored at any given time
void store_data(FwSizeType index, const U8 *source, FwSizeType size)
store data into a set index in the data store
bool isEmpty()
Is the heap empty?
bool push(FwQueuePriorityType value, FwSizeType id)
Push an item onto the heap.
#define FW_MAX(a, b)
MAX macro.
A variable-length byte array.
bool isFull()
Is the heap full?
Os::ConditionVariable m_empty
Queue empty condition variable to support blocking.
FwSizeType find_index()
find an available index to store data from the list
FwSizeType getSize() const
Get the current number of elements on the heap.
uint8_t U8
8-bit unsigned integer
Os::ConditionVariable m_full
Queue full condition variable to support blocking.
void load_data(FwSizeType index, U8 *destination, FwSizeType capacity)
load data from a set index in the data store
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void wait(Os::Mutex &mutex)
wait on a condition variable
Memory Allocation base class.
FwEnumStoreType m_id
Identifier for the queue, used for memory allocation.
A read-only abstract superclass for StringBase.
Status create(FwEnumStoreType id, const Fw::ConstStringBase &name, FwSizeType depth, FwSizeType messageSize) override
create queue storage
void teardown() override
teardown the queue
locks a mutex within the current scope
static constexpr FwSizeType ELEMENT_SIZE
Exposes the ELEMENT_SIZE for pre-allocation.
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue
Defines a base class for a memory allocator for classes.
Os::Mutex m_data_lock
Lock against data manipulation.
void create(FwSizeType capacity, Fw::ByteArray heap_allocation)
MaxHeap creation.
virtual void deallocate(const FwEnumStoreType identifier, void *ptr)=0
void return_index(FwSizeType index)
return index to the circular data structure
virtual ~PriorityQueue()
default queue destructor
Types::MaxHeap m_heap
MaxHeap data store for tracking priority.
FwSizeType getMessagesAvailable() const override
get number of messages available
void teardown()
MaxHeap teardown.
PriorityQueueHandle m_handle