Foundation
|
Atomic, bounded single-producer single-consumer FIFO ring buffer with a fixed maximum size. More...
#include <Queue.hpp>
Public Member Functions | |
SPSCQueue (size_t size, Allocator *alloc) | |
Construct the SPSC Queue. | |
template<typename U > | |
bool | Push (U &&data) |
Try to push data into the queue. | |
bool | Pop (T &out) |
Try to pop data from the queue. | |
Private Attributes | |
const size_t | mModulo |
Vector< T > | mBuffer |
Atomic< size_t > | mRead {} |
Atomic< size_t > | mWrite {} |
size_t | mReadCached {} |
size_t | mWriteCached {} |
Atomic, bounded single-producer single-consumer FIFO ring buffer with a fixed maximum size.
T | Data type. |
|
inline |
Construct the SPSC Queue.
size | Bounded size of the queue. Must be a power of two. |
alloc | Allocator to use for internal storage. |
Try to pop data from the queue.
out | Reference to receive the popped data. This is only valid if the function returns true. The values are move-constructed from the queue. |
|
inline |
Try to push data into the queue.
data | The data to push. |
|
private |
|
private |