|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Bounded multi-producer, single-consumer queue of deferred operations. More...
#include <PendingQueue.hpp>
Inheritance diagram for MayaFlux::Memory::PendingQueue< T, Capacity >:
Collaboration diagram for MayaFlux::Memory::PendingQueue< T, Capacity >:Classes | |
| struct | Cell |
Public Member Functions | |
| template<typename Apply > | |
| size_t | drain (Apply &&apply) |
| Apply and remove every published operation in claim order. | |
| bool | has_pending () const noexcept |
| Cheap check for claimed operations awaiting a drain. | |
| PendingQueue & | operator= (const PendingQueue &)=delete |
| PendingQueue & | operator= (PendingQueue &&)=delete |
| PendingQueue () noexcept | |
| PendingQueue (const PendingQueue &)=delete | |
| PendingQueue (PendingQueue &&)=delete | |
| bool | push (T &&value) noexcept(std::is_nothrow_move_assignable_v< T >) |
| Enqueue an operation from any thread. | |
| ~PendingQueue ()=default | |
Private Attributes | |
| std::array< Cell, Capacity > | m_cells |
| std::atomic< size_t > | m_dequeue { 0 } |
| std::atomic< size_t > | m_enqueue { 0 } |
Static Private Attributes | |
| static constexpr size_t | MASK = Capacity - 1 |
Bounded multi-producer, single-consumer queue of deferred operations.
Producers on any thread push an operation; the one owner of the guarded container drains the queue at a point where mutation is safe and applies each operation in the order it was claimed. Each cell carries its own sequence number, so a producer only claims a cell that is free and a consumer only reads a cell whose payload has been published. A full queue rejects the push without disturbing any other claim.
Capacity must be a power of two. T must be default constructible and move assignable; the drained cell is reset so the queue never retains a payload (for example a shared_ptr) past its application.
Only one thread may call drain() at a time.
Definition at line 33 of file PendingQueue.hpp.