cds
2.3.2
|
A variation of Michael & Scott's lock-free queue. More...
#include <cds/container/moir_queue.h>
Data Structures | |
struct | rebind |
Rebind template arguments. More... | |
Public Types | |
typedef T | value_type |
Value type stored in the queue. | |
typedef base_class::gc | gc |
Garbage collector. | |
typedef base_class::back_off | back_off |
Back-off strategy. | |
typedef maker::allocator_type | allocator_type |
Allocator type used for allocate/deallocate the nodes. | |
typedef base_class::item_counter | item_counter |
Item counting policy used. | |
typedef base_class::stat | stat |
Internal statistics policy used. | |
typedef base_class::memory_model | memory_model |
Memory ordering. See cds::opt::memory_model option. | |
Public Member Functions | |
MoirQueue () | |
Initializes empty queue. | |
~MoirQueue () | |
Destructor clears the queue. | |
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. | |
template<typename Func > | |
bool | enqueue_with (Func f) |
Enqueues data to queue using a functor. More... | |
template<typename... Args> | |
bool | emplace (Args &&... args) |
Enqueues data of type value_type constructed with std::forward<Args>(args)... | |
bool | push (value_type const &val) |
Synonym for enqueue() function. | |
bool | push (value_type &&val) |
Synonym for enqueue() function, move semantics. | |
template<typename Func > | |
bool | push_with (Func f) |
Synonym for enqueue_with() function. | |
bool | dequeue (value_type &dest) |
Dequeues a value from the queue. More... | |
template<typename Func > | |
bool | dequeue_with (Func f) |
Dequeues a value using a functor. More... | |
bool | pop (value_type &dest) |
Synonym for dequeue() function. | |
template<typename Func > | |
bool | pop_with (Func f) |
Synonym for dequeue_with() function. | |
void | clear () |
Clear the queue. More... | |
bool | empty () const |
Checks if the queue is empty. | |
size_t | size () const |
Returns queue's item count (see intrusive::MSQueue::size for explanation) | |
const stat & | statistics () const |
Returns refernce to internal statistics. | |
Static Public Attributes | |
static constexpr const size_t | c_nHazardPtrCount = base_class::c_nHazardPtrCount |
Count of hazard pointer required for the algorithm. | |
Additional Inherited Members | |
Private Types inherited from cds::intrusive::MSQueue< GC, intrusive::msqueue::node< T >, Traits > | |
typedef GC | gc |
Garbage collector. | |
typedef intrusive::msqueue::node< T > | value_type |
type of value to be stored in the queue | |
typedef Traits | traits |
Queue traits. | |
typedef traits::hook | hook |
hook type | |
typedef hook::node_type | node_type |
node type | |
typedef traits::disposer | disposer |
disposer used | |
typedef get_node_traits< value_type, node_type, hook >::type | node_traits |
node traits | |
typedef single_link::get_link_checker< node_type, traits::link_checker >::type | link_checker |
link checker | |
typedef traits::back_off | back_off |
back-off strategy | |
typedef traits::item_counter | item_counter |
Item counter class. | |
typedef traits::stat | stat |
Internal statistics. | |
typedef traits::memory_model | memory_model |
Memory ordering. See cds::opt::memory_model option. | |
Private Member Functions inherited from cds::intrusive::MoirQueue< GC, intrusive::msqueue::node< T >, Traits > | |
value_type * | dequeue () |
Dequeues a value from the queue. More... | |
value_type * | pop () |
Synonym for dequeue function. | |
Private Member Functions inherited from cds::intrusive::MSQueue< GC, intrusive::msqueue::node< T >, Traits > | |
MSQueue () | |
Initializes empty queue. | |
~MSQueue () | |
Destructor clears the queue. More... | |
bool | enqueue (value_type &val) |
Enqueues val value into the queue. More... | |
value_type * | dequeue () |
Dequeues a value from the queue. More... | |
bool | push (value_type &val) |
Synonym for enqueue() function. | |
value_type * | pop () |
Synonym for dequeue() function. | |
bool | empty () const |
Checks if the queue is empty. | |
void | clear () |
Clear the queue. More... | |
size_t | size () const |
Returns queue's item count. More... | |
stat const & | statistics () const |
Returns reference to internal statistics. | |
Static Private Attributes inherited from cds::intrusive::MSQueue< GC, intrusive::msqueue::node< T >, Traits > | |
static constexpr const size_t | c_nHazardPtrCount |
Count of hazard pointer required for the algorithm. | |
A variation of Michael & Scott's lock-free queue.
It is non-intrusive version of cds::intrusive::MoirQueue
.
Template arguments:
GC
- garbage collector type: gc::HP
, gc::DHP
T
- a type stored in the queue.Traits
- queue traits, default is msqueue::traits
. You can use msqueue::make_traits
metafunction to make your traits or just derive your traits from msqueue::traits
:
|
inline |
Clear the queue.
The function repeatedly calls dequeue until it returns nullptr
. The disposer defined in template Traits
is called for each item that can be safely disposed.
|
inline |
Dequeues a value from the queue.
If queue is not empty, the function returns true
, dest
contains copy of dequeued value. The assignment operator for type value_type is invoked. If queue is empty, the function returns false
, dest
is unchanged.
|
inline |
Dequeues a value using a functor.
Func
is a functor called to copy dequeued value. The functor takes one argument - a reference to removed node:
The functor is called only if the queue is not empty.
|
inline |
Enqueues val
value into the queue.
The function makes queue node in dynamic memory calling copy constructor for val
and then it calls intrusive::MoirQueue::enqueue
. Returns true
if success, false
otherwise.
|
inline |
Enqueues data
to queue using a functor.
Func
is a functor calling to create a new node. The functor should initialize creating node and it takes one argument - a reference to a new node of type value_type :