cds  2.3.1
cds::intrusive::VyukovMPMCCycleQueue< T, Traits > Class Template Reference

Vyukov's MPMC bounded queue. More...

#include <cds/intrusive/vyukov_mpmc_cycle_queue.h>

Inheritance diagram for cds::intrusive::VyukovMPMCCycleQueue< T, Traits >:
cds::container::VyukovMPMCCycleQueue< T *, Traits >

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_typedequeue ()
 Dequeues an item from queue. More...
 
bool push (value_type &data)
 Synonym for enqueue()
 
value_typepop ()
 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
 

Detailed Description

template<typename T, typename Traits = vyukov_queue::traits>
class cds::intrusive::VyukovMPMCCycleQueue< T, Traits >

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:

Instead of saving copy of enqueued data, the intrusive implementation stores pointer to passed data.

Examples:
#include <cds/intrusive/vyukov_mpmc_cycle_queue.h>
struct Foo {
...
};
// Queue of Foo pointers, capacity is 1024, statically allocated buffer:
>::type
> static_queue;
static_queue stQueue;
// Queue of Foo pointers, capacity is 1024, dynamically allocated buffer:
struct queue_traits: public cds::intrusive::vyukov_queue::traits
{
};
dynamic_queue dynQueue( 1024 );

Constructor & Destructor Documentation

◆ VyukovMPMCCycleQueue()

template<typename T , typename Traits = vyukov_queue::traits>
cds::intrusive::VyukovMPMCCycleQueue< T, Traits >::VyukovMPMCCycleQueue ( size_t  nCapacity = 0)
inline

Constructs the queue of capacity nCapacity.

For cds::opt::v::uninitialized_static_buffer the nCapacity parameter is ignored.

Member Function Documentation

◆ clear() [1/2]

template<typename T , typename Traits = vyukov_queue::traits>
template<typename Disposer >
void cds::intrusive::VyukovMPMCCycleQueue< T, Traits >::clear ( Disposer  f)
inline

Clears queue in lock-free manner.

f parameter is a functor to dispose removed items. The interface of Disposer is:

struct myDisposer {
void operator ()( T * val );
};

The disposer will be called immediately for each item.

◆ clear() [2/2]

template<typename T , typename Traits = vyukov_queue::traits>
void cds::intrusive::VyukovMPMCCycleQueue< T, Traits >::clear ( )
inline

Clears the queue.

This function uses the disposer that is specified in Traits.

◆ dequeue()

template<typename T , typename Traits = vyukov_queue::traits>
value_type* cds::intrusive::VyukovMPMCCycleQueue< T, Traits >::dequeue ( )
inline

Dequeues an item from queue.

Traits::disposer is not called. You may manually delete the returned pointer.

If queue is empty, returns nullptr.

◆ enqueue()

template<typename T , typename Traits = vyukov_queue::traits>
bool cds::intrusive::VyukovMPMCCycleQueue< T, Traits >::enqueue ( value_type data)
inline

Enqueues data to queue.

Note
The intrusive queue stores pointer to data passed, not the copy of data.

◆ size()

template<typename T , typename Traits = vyukov_queue::traits>
size_t cds::intrusive::VyukovMPMCCycleQueue< T, Traits >::size ( ) const
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.


The documentation for this class was generated from the following file:

cds 2.3.1 Developed by Maxim Khizhinsky aka khizmax 2007 - 2017
Autogenerated Fri Sep 1 2017 08:47:25 by Doxygen 1.8.13