cds
2.3.2
|
Vyukov's MPMC bounded queue. More...
#include <cds/intrusive/vyukov_mpmc_cycle_queue.h>
Data Structures | |
struct | rebind |
Rebind template arguments. More... | |
Public Types | |
typedef T | value_type |
type of data to be stored in the queue | |
typedef Traits | traits |
Queue traits. | |
typedef traits::item_counter | item_counter |
Item counter type. | |
typedef traits::memory_model | memory_model |
Memory ordering. See cds::opt::memory_model option. | |
typedef traits::disposer | disposer |
Item disposer. | |
typedef traits::back_off | back_off |
back-off strategy | |
Public Member Functions | |
VyukovMPMCCycleQueue (size_t nCapacity=0) | |
Constructs the queue of capacity nCapacity . More... | |
bool | enqueue (value_type &data) |
Enqueues data to queue. More... | |
value_type * | dequeue () |
Dequeues an item from queue. More... | |
bool | push (value_type &data) |
Synonym for enqueue() | |
value_type * | pop () |
Synonym for dequeue() | |
template<typename Disposer > | |
void | clear (Disposer f) |
Clears queue in lock-free manner. More... | |
void | clear () |
Clears the queue. More... | |
bool | empty () const |
Checks if the queue is empty. | |
size_t | size () const |
Returns queue's item count. More... | |
size_t | capacity () const |
Returns capacity of the queue. | |
Additional Inherited Members | |
Private Types inherited from cds::container::VyukovMPMCCycleQueue< T *, Traits > | |
typedef T * | value_type |
Value type to be stored in the queue. | |
typedef Traits | traits |
Queue traits. | |
typedef traits::item_counter | item_counter |
Item counter type. | |
typedef traits::memory_model | memory_model |
Memory ordering. See cds::opt::memory_model option. | |
typedef traits::value_cleaner | value_cleaner |
Value cleaner, see vyukov_queue::traits::value_cleaner . | |
typedef traits::back_off | back_off |
back-off strategy | |
Private Member Functions inherited from cds::container::VyukovMPMCCycleQueue< T *, Traits > | |
VyukovMPMCCycleQueue (size_t nCapacity=0) | |
Constructs the queue of capacity nCapacity . More... | |
bool | enqueue_with (Func f) |
Enqueues data to the queue using a functor. More... | |
bool | enqueue (value_type const &val) |
Enqueues val value into the queue. More... | |
bool | enqueue (value_type &&val) |
Enqueues val value into the queue, move semantics. | |
bool | push (value_type const &data) |
Synonym for enqueue( value_type const& ) | |
bool | push (value_type &&data) |
Synonym for enqueue( value_type&& ) | |
bool | push_with (Func f) |
Synonym for enqueue_with() | |
bool | emplace (Args &&... args) |
Enqueues data of type value_type constructed with std::forward<Args>(args)... | |
bool | dequeue_with (Func f) |
Dequeues a value using a functor. More... | |
bool | dequeue (value_type &dest) |
Dequeues a value from the queue. More... | |
bool | pop (value_type &data) |
Synonym for dequeue() | |
bool | pop_with (Func f) |
Synonym for dequeue_with() | |
std::enable_if< SC, value_type *>::type | front () |
Returns a pointer to top element of the queue or nullptr if queue is empty (only for single-consumer version) | |
std::enable_if< SC, bool >::type | pop_front () |
Pops top element; returns true if queue is not empty, false otherwise (only for single-consumer version) | |
bool | empty () const |
Checks if the queue is empty. | |
void | clear () |
Clears the queue. | |
size_t | size () const |
Returns queue's item count. More... | |
size_t | capacity () const |
Returns capacity of the queue. | |
Static Private Attributes inherited from cds::container::VyukovMPMCCycleQueue< T *, Traits > | |
static constexpr bool const | c_single_consumer |
true for single-consumer version, false otherwise | |
Vyukov's MPMC bounded queue.
This algorithm is developed by Dmitry Vyukov (see http://www.1024cores.net)
Implementation of intrusive version is based on container::VyukovMPMCCycleQueue.
Template parameters:
T
- type stored in queue.Traits
- queue traits, default is vyukov_queue::traits
. You can use vyukov_queue::make_traits
metafunction to make your traits or just derive your traits from vyukov_queue::traits
: Instead of saving copy of enqueued data, the intrusive implementation stores pointer to passed data.
|
inline |
Constructs the queue of capacity nCapacity
.
For cds::opt::v::uninitialized_static_buffer
the nCapacity
parameter is ignored.
|
inline |
Clears queue in lock-free manner.
f
parameter is a functor to dispose removed items. The interface of Disposer
is:
The disposer will be called immediately for each item.
|
inline |
Clears the queue.
This function uses the disposer that is specified in Traits
.
|
inline |
Dequeues an item from queue.
Traits::disposer
is not called. You may manually delete the returned pointer.
If queue is empty, returns nullptr
.
|
inline |
Enqueues data
to queue.
data
passed, not the copy of data
.
|
inline |
Returns queue's item count.
The value returned depends on vyukov_queue::traits::item_counter
option. For atomicity::empty_item_counter
, this function always returns 0.