13 #ifndef OS_GENERIC_TYPES_ATOMIC_QUEUE_HPP 14 #define OS_GENERIC_TYPES_ATOMIC_QUEUE_HPP 23 class AtomicQueueWrapAroundTest;
52 friend class ::AtomicQueueWrapAroundTest;
152 bool isCreated()
const {
return this->m_slots !=
nullptr && this->m_capacity > 0; }
156 static constexpr
FwSizeType MAX_CAS_RETRIES = 100;
171 std::atomic<FwSizeType> sequence;
180 return (this->m_mask != 0) ? (pos & this->m_mask) : (pos % this->m_capacity);
184 static U32 computeChecksum(
const U8* buffer,
FwSizeType size);
194 bool enqueueInternal(
const U8* buffer,
FwSizeType size);
202 std::atomic<FwSizeType> m_enqueuePos;
203 std::atomic<FwSizeType> m_dequeuePos;
211 #endif // OS_GENERIC_TYPES_ATOMIC_QUEUE_HPP AtomicQueue & operator=(const AtomicQueue &)=delete
PlatformSizeType FwSizeType
~AtomicQueue()
AtomicQueue destructor.
AtomicQueue()
AtomicQueue constructor.
FwSizeType getSize() const
Get the current number of elements in the queue.
bool enqueueBlocking(const U8 *buffer, FwSizeType size, bool blockIfFull)
Enqueue with optional blocking (multi-producer safe, O(1))
A lock-free MPMC FIFO circular buffer with fixed-size buffer storage.
bool isEmpty() const
Check if the queue is empty.
bool isFull() const
Check if the queue is full.
bool isCreated() const
Check if queue has been successfully created.
uint8_t U8
8-bit unsigned integer
Memory Allocation base class.
void teardown()
Teardown the queue and free allocated memory.
FwSizeType getBufferSize() const
Get the buffer size for each message.
bool enqueue(const U8 *buffer, FwSizeType size)
Enqueue a message (multi-producer safe, non-blocking, O(1))
FwSizeType getCapacity() const
Get the maximum capacity of the queue.
Defines a base class for a memory allocator for classes.
void create(FwSizeType numBuffers, FwSizeType bufferSize, Fw::MemAllocator &allocator, FwEnumStoreType allocatorId)
Create the queue with embedded buffer storage.
bool dequeue(U8 *buffer, FwSizeType capacity, FwSizeType &actualSize)
Dequeue a message (multi-consumer safe, non-blocking, O(1))