cds  2.3.2
cds::container::FCStack< T, Stack, Traits > Class Template Reference

Flat-combining stack. More...

#include <cds/container/fcstack.h>

Public Types

typedef T value_type
 Value type.
 
typedef Stack stack_type
 Sequential stack class.
 
typedef Traits traits
 Stack traits.
 
typedef traits::stat stat
 Internal statistics type.
 

Public Member Functions

 FCStack ()
 Initializes empty stack object.
 
 FCStack (unsigned int nCompactFactor, unsigned int nCombinePassCount)
 Initializes empty stack object and gives flat combining parameters. More...
 
bool push (value_type const &val)
 Inserts a new element at the top of stack. More...
 
bool push (value_type &&val)
 Inserts a new element at the top of stack (move semantics) More...
 
bool pop (value_type &val)
 Removes the element on top of the stack. More...
 
void clear ()
 Clears the stack.
 
template<typename Func >
void apply (Func f)
 Exclusive access to underlying stack object. More...
 
template<typename Func >
void apply (Func f) const
 Exclusive access to underlying stack object. More...
 
size_t size () const
 Returns the number of elements in the stack. More...
 
bool empty ()
 Checks if the stack 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 Stack = std::stack<T>, typename Traits = fcstack::traits>
class cds::container::FCStack< T, Stack, Traits >

Flat-combining stack.

Flat combining sequential stack.

Template parameters:

  • T - a value type stored in the stack
  • Stack - sequential stack implementation, default is std::stack<T>
  • Trats - type traits of flat combining, default is fcstack::traits fcstack::make_traits metafunction can be used to construct specialized fcstack::traits

Constructor & Destructor Documentation

◆ FCStack()

template<typename T , class Stack = std::stack<T>, typename Traits = fcstack::traits>
cds::container::FCStack< T, Stack, Traits >::FCStack ( unsigned int  nCompactFactor,
unsigned int  nCombinePassCount 
)
inline

Initializes empty stack 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

◆ apply() [1/2]

template<typename T , class Stack = std::stack<T>, typename Traits = fcstack::traits>
template<typename Func >
void cds::container::FCStack< T, Stack, Traits >::apply ( Func  f)
inline

Exclusive access to underlying stack object.

The functor f can do any operation with underlying stack_type in exclusive mode. For example, you can iterate over the stack. Func signature is:

void f( stack_type& stack );

◆ apply() [2/2]

template<typename T , class Stack = std::stack<T>, typename Traits = fcstack::traits>
template<typename Func >
void cds::container::FCStack< T, Stack, Traits >::apply ( Func  f) const
inline

Exclusive access to underlying stack object.

The functor f can do any operation with underlying stack_type in exclusive mode. For example, you can iterate over the stack. Func signature is:

void f( stack_type const& stack );

◆ empty()

template<typename T , class Stack = std::stack<T>, typename Traits = fcstack::traits>
bool cds::container::FCStack< T, Stack, Traits >::empty ( )
inline

Checks if the stack is empty.

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

◆ pop()

template<typename T , class Stack = std::stack<T>, typename Traits = fcstack::traits>
bool cds::container::FCStack< T, Stack, Traits >::pop ( value_type val)
inline

Removes the element on top of the stack.

val takes a copy of top element

◆ push() [1/2]

template<typename T , class Stack = std::stack<T>, typename Traits = fcstack::traits>
bool cds::container::FCStack< T, Stack, Traits >::push ( value_type const &  val)
inline

Inserts a new element at the top of stack.

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

◆ push() [2/2]

template<typename T , class Stack = std::stack<T>, typename Traits = fcstack::traits>
bool cds::container::FCStack< T, Stack, Traits >::push ( value_type &&  val)
inline

Inserts a new element at the top of stack (move semantics)

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

◆ size()

template<typename T , class Stack = std::stack<T>, typename Traits = fcstack::traits>
size_t cds::container::FCStack< T, Stack, Traits >::size ( ) const
inline

Returns the number of elements in the stack.

Note that size() == 0 is not mean that the stack 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.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:19 by Doxygen 1.8.13