cds  2.3.1
cds::container::FCQueue< T, Queue, Traits > Class Template Reference

Flat-combining queue. More...

#include <cds/container/fcqueue.h>

Public Types

typedef T value_type
 Value type.
 
typedef Queue queue_type
 Sequential queue class.
 
typedef Traits traits
 Queue type traits.
 
typedef traits::stat stat
 Internal statistics type.
 

Public Member Functions

 FCQueue ()
 Initializes empty queue object.
 
 FCQueue (unsigned int nCompactFactor, unsigned int nCombinePassCount)
 Initializes empty queue object and gives flat combining parameters. More...
 
bool enqueue (value_type const &val)
 Inserts a new element at the end of the queue. More...
 
bool push (value_type const &val)
 Inserts a new element at the end of the queue (a synonym for enqueue)
 
bool enqueue (value_type &&val)
 Inserts a new element at the end of the queue (move semantics) More...
 
bool push (value_type &&val)
 Inserts a new element at the end of the queue (move semantics, synonym for enqueue)
 
bool dequeue (value_type &val)
 Removes the next element from the queue. More...
 
bool pop (value_type &val)
 Removes the next element from the queue (a synonym for dequeue)
 
void clear ()
 Clears the queue.
 
size_t size () const
 Returns the number of elements in the queue. More...
 
bool empty () const
 Checks if the queue is empty. More...
 
stat const & statistics () const
 Internal statistics.
 

Static Public Attributes

static constexpr const bool c_bEliminationEnabled = traits::enable_elimination
 true if elimination is enabled
 

Protected Types

typedef cds::algo::flat_combining::kernel< fc_record, traitsfc_kernel
 Flat combining kernel.
 

Detailed Description

template<typename T, class Queue = std::queue<T>, typename Traits = fcqueue::traits>
class cds::container::FCQueue< T, Queue, Traits >

Flat-combining queue.

Flat combining sequential queue. The class can be considered as a concurrent FC-based wrapper for std::queue.

Template parameters:

  • T - a value type stored in the queue
  • Queue - sequential queue implementation, default is std::queue<T>
  • Trats - type traits of flat combining, default is fcqueue::traits. fcqueue::make_traits metafunction can be used to construct fcqueue::traits specialization.

Constructor & Destructor Documentation

◆ FCQueue()

template<typename T , class Queue = std::queue<T>, typename Traits = fcqueue::traits>
cds::container::FCQueue< T, Queue, Traits >::FCQueue ( unsigned int  nCompactFactor,
unsigned int  nCombinePassCount 
)
inline

Initializes empty queue object and gives flat combining parameters.

Parameters
nCompactFactorFlat combining: publication list compacting factor
nCombinePassCountFlat combining: number of combining passes for combiner thread

Member Function Documentation

◆ dequeue()

template<typename T , class Queue = std::queue<T>, typename Traits = fcqueue::traits>
bool cds::container::FCQueue< T, Queue, Traits >::dequeue ( value_type val)
inline

Removes the next element from the queue.

val takes a copy of the element

◆ empty()

template<typename T , class Queue = std::queue<T>, typename Traits = fcqueue::traits>
bool cds::container::FCQueue< T, Queue, Traits >::empty ( ) const
inline

Checks if the queue is empty.

If the combining is in process the function waits while combining done.

◆ enqueue() [1/2]

template<typename T , class Queue = std::queue<T>, typename Traits = fcqueue::traits>
bool cds::container::FCQueue< T, Queue, Traits >::enqueue ( value_type const &  val)
inline

Inserts a new element at the end of the queue.

The content of the new element initialized to a copy of val.

The function always returns true

◆ enqueue() [2/2]

template<typename T , class Queue = std::queue<T>, typename Traits = fcqueue::traits>
bool cds::container::FCQueue< T, Queue, Traits >::enqueue ( value_type &&  val)
inline

Inserts a new element at the end of the queue (move semantics)

val is moved to inserted element

◆ size()

template<typename T , class Queue = std::queue<T>, typename Traits = fcqueue::traits>
size_t cds::container::FCQueue< T, Queue, Traits >::size ( ) const
inline

Returns the number of elements in the queue.

Note that size() == 0 is not mean that the queue is empty because combining record can be in process. To check emptiness use empty function.


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:46:58 by Doxygen 1.8.13