Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
Thread-safe lock-free node-based intrusive multi-producer single-consumer queue. More...
#include <mpsc_queue.h>
Public Types | |
typedef OwnershipPolicy< T >::Pointer | Pointer |
Pointer type. More... | |
Public Member Functions | |
void | push_back (T &elem) |
Add object to the end of the queue. Can be called concurrently. Acquires ownership of elem . After this call returns, any thread calling pop_front_exclusive() or try_pop_front_exclusive() is guaranteed to see a non-empty queue. But note that the latter can still fail if called concurrently with push_back(). More... | |
Pointer | try_pop_front_exclusive () |
Try to remove object from the beginning of the queue (non-blocking version). Should NOT be called concurrently. Releases ownership of the returned object. More... | |
Pointer | pop_front_exclusive () |
Remove object from the beginning of the queue (blocking version). Should NOT be called concurrently. Releases ownership of the returned object. More... | |
Thread-safe lock-free node-based intrusive multi-producer single-consumer queue.
Provides sequential consistency.
Based on Dmitry Vyukov algorithm:
T | defines object type, it must inherit MpscQueueNode. |
OwnershipPolicy | defines ownership policy which is used to acquire an element ownership when it's added to the queue and release ownership when it's removed from the queue. |
Node | defines base class of queue nodes. It is needed if MpscQueueNode is used with non-default tag. |
Definition at line 45 of file mpsc_queue.h.
typedef OwnershipPolicy<T>::Pointer roc::core::MpscQueue< T, OwnershipPolicy, Node >::Pointer |
Pointer type.
Definition at line 50 of file mpsc_queue.h.
|
inline |
Remove object from the beginning of the queue (blocking version). Should NOT be called concurrently. Releases ownership of the returned object.
Definition at line 114 of file mpsc_queue.h.
|
inline |
Add object to the end of the queue. Can be called concurrently. Acquires ownership of elem
. After this call returns, any thread calling pop_front_exclusive() or try_pop_front_exclusive() is guaranteed to see a non-empty queue. But note that the latter can still fail if called concurrently with push_back().
Definition at line 73 of file mpsc_queue.h.
|
inline |
Try to remove object from the beginning of the queue (non-blocking version). Should NOT be called concurrently. Releases ownership of the returned object.
Definition at line 91 of file mpsc_queue.h.