Games Task Scheduler (GTS)
A multi-processor scheduling framework for games engines
|
A multi-producer, multi-consumer queue. Properties: More...
#include <QueueMPSC.h>
Inherits gts::AlignedAllocator< GTS_NO_SHARING_CACHE_LINE_SIZE >.
Public Types | |
using | queue_type = internal::TicketQueueMPSC< T, TMutex, TAllocator > |
using | value_type = typename queue_type::value_type |
using | mutex_type = typename queue_type::mutex_type |
using | size_type = typename queue_type::size_type |
using | allocator_type = typename queue_type::allocator_type |
Public Member Functions | |
QueueMPSC (size_t numSubQueuesPow2=Thread::getHardwareThreadCount(), allocator_type const &allocator=allocator_type()) | |
~QueueMPSC () | |
QueueMPSC (QueueMPSC const &other) | |
QueueMPSC (QueueMPSC &&other) | |
QueueMPSC & | operator= (QueueMPSC const &other) |
QueueMPSC & | operator= (QueueMPSC &&other) |
bool | empty () const |
size_type | size () const |
size_type | capacity () const |
allocator_type | get_allocator () const |
void | reserve (size_type sizePow2) |
void | clear () |
bool | tryPush (const value_type &val) |
bool | tryPush (value_type &&val) |
bool | tryPop (value_type &out) |
A multi-producer, multi-consumer queue. Properties:
T | The type stored in the container. |
TMutex | The mutex type that guards access to the container. |
TAllocator | The allocator used for T. |
TSize | The integral type used for the container size. |
|
explicit |
Constructs an empty container with 'numSubQueuesPow2' sub vectors and with the given 'allocator'.
gts::QueueMPSC< T, TMutex, TAllocator >::~QueueMPSC |
Destructs the container. The destructors of the elements are called and the used storage is deallocated.
gts::QueueMPSC< T, TMutex, TAllocator >::QueueMPSC | ( | QueueMPSC< T, TMutex, TAllocator > const & | other | ) |
Copy constructor. Constructs the container with the copy of the contents of 'other'.
gts::QueueMPSC< T, TMutex, TAllocator >::QueueMPSC | ( | QueueMPSC< T, TMutex, TAllocator > && | other | ) |
Move constructor. Constructs the container with the contents of other using move semantics. After the move, other is invalid.
QueueMPSC< T, TMutex, TAllocator >::size_type gts::QueueMPSC< T, TMutex, TAllocator >::capacity |
void gts::QueueMPSC< T, TMutex, TAllocator >::clear |
Removes all elements from the queue.
bool gts::QueueMPSC< T, TMutex, TAllocator >::empty |
QueueMPSC< T, TMutex, TAllocator >::allocator_type gts::QueueMPSC< T, TMutex, TAllocator >::get_allocator |
QueueMPSC< T, TMutex, TAllocator > & gts::QueueMPSC< T, TMutex, TAllocator >::operator= | ( | QueueMPSC< T, TMutex, TAllocator > && | other | ) |
Move assignment operator. Replaces the contents with those of other using move semantics. After the move, other is invalid.
QueueMPSC< T, TMutex, TAllocator > & gts::QueueMPSC< T, TMutex, TAllocator >::operator= | ( | QueueMPSC< T, TMutex, TAllocator > const & | other | ) |
Copy assignment operator. Replaces the contents with a copy of the contents of 'other'.
void gts::QueueMPSC< T, TMutex, TAllocator >::reserve | ( | size_type | sizePow2 | ) |
Increases the capacity of the queue. Does nothing if 'sizePow2' < capacity.
QueueMPSC< T, TMutex, TAllocator >::size_type gts::QueueMPSC< T, TMutex, TAllocator >::size |
bool gts::QueueMPSC< T, TMutex, TAllocator >::tryPop | ( | value_type & | out | ) |
Pops an element from the queue and copies it into 'out'.
bool gts::QueueMPSC< T, TMutex, TAllocator >::tryPush | ( | const value_type & | val | ) |
Copies 'val' into the queue.
bool gts::QueueMPSC< T, TMutex, TAllocator >::tryPush | ( | value_type && | val | ) |
Moves 'val' into the queue.