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 &obj) |
Add object to the end of the queue. Can be called concurrently. Acquires ownership of obj . 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 should 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. |
Definition at line 40 of file mpsc_queue.h.
typedef OwnershipPolicy<T>::Pointer roc::core::MpscQueue< T, OwnershipPolicy >::Pointer |
Pointer type.
Definition at line 45 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 110 of file mpsc_queue.h.
|
inline |
Add object to the end of the queue. Can be called concurrently. Acquires ownership of obj
. 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 68 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 87 of file mpsc_queue.h.