|
cds
1.4.0
|
Treiber's stack algorithm. More...
#include <cds/container/treiber_stack.h>
Data Structures | |
| struct | rebind |
| Rebind template arguments. More... | |
Public Types | |
| typedef T | value_type |
| Value type stored in the stack. | |
| typedef base_class::gc | gc |
| Garbage collector used. | |
| typedef base_class::back_off | back_off |
| Back-off strategy used. | |
| typedef options::allocator_type | allocator_type |
| Allocator type used for allocate/deallocate the nodes. | |
| typedef options::memory_model | memory_model |
| Memory ordering. See cds::opt::memory_order option. | |
| typedef base_class::stat | stat |
| Internal statistics policy used. | |
Public Types inherited from cds::intrusive::TreiberStack< GC, cds::intrusive::single_link::node< T >, Options... > | |
|
typedef cds::intrusive::single_link::node < T > | value_type |
| type of value stored in the stack | |
| typedef options::hook | hook |
| hook type | |
| typedef hook::node_type | node_type |
| node type | |
| typedef options::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, options::link_checker >::type | link_checker |
| link checker | |
| typedef options::memory_model | memory_model |
| Memory ordering. See cds::opt::memory_model option. | |
| typedef options::item_counter | item_counter |
| Item counting policy used. | |
| typedef options::stat | stat |
| Internal statistics policy used. | |
| typedef GC | gc |
| Garbage collector. | |
| typedef options::back_off | back_off |
| back-off strategy | |
Public Member Functions | |
| TreiberStack () | |
| Constructs empty stack. | |
| ~TreiberStack () | |
| Clears the stack on destruction. | |
| bool | push (const value_type &val) |
Push the item val on the stack. | |
| template<typename... Args> | |
| bool | emplace (Args &&...args) |
Pushes data of type value_type constructed with std::forward<Args>(args)... More... | |
| bool | pop (value_type &val) |
| Pop an item from the stack. More... | |
| bool | empty () const |
| Check if stack is empty. | |
| void | clear () |
| Clear the stack. | |
| size_t | size () const |
| Returns stack's item count. More... | |
| stat const & | statistics () const |
| Returns reference to internal statistics. | |
Public Member Functions inherited from cds::intrusive::TreiberStack< GC, cds::intrusive::single_link::node< T >, Options... > | |
| TreiberStack () | |
| Constructs empty stack. | |
| ~TreiberStack () | |
| Destructor calls clear member function. | |
| bool | push (value_type &val) |
Push the item val on the stack. More... | |
| value_type * | pop () |
| Pop an item from the stack. More... | |
| bool | empty () const |
| Check if stack is empty. | |
| void | clear () |
| Clear the stack. More... | |
| size_t | size () const |
| Returns stack's item count. More... | |
| stat const & | statistics () const |
| Returns reference to internal statistics. | |
Protected Types | |
| typedef options::node_type | node_type |
| stack node type (derived from intrusive::single_link::node) | |
Additional Inherited Members | |
Protected Attributes inherited from cds::intrusive::TreiberStack< GC, cds::intrusive::single_link::node< T >, Options... > | |
| node_type::atomic_node_ptr | m_Top |
| Top of the stack. | |
| item_counter | m_ItemCounter |
| Item counter. | |
| stat | m_stat |
| Internal statistics. | |
Treiber's stack algorithm.
It is non-intrusive version of Treiber's stack algorithm based on intrusive implementation intrusive::TreiberStack.
Template arguments:
GC - garbage collector type: gc::HP, gc::HRC, gc::PTBT - type stored in the stack. It should be default-constructible, copy-constructible, assignable type.Options - optionsAvailable Options:
std::allocator). Default is CDS_DEFAULT_ALLOCATOR
|
inline |
Pushes data of type value_type constructed with std::forward<Args>(args)...
This function is available only for compiler that supports variadic template and move semantics
|
inline |
Pop an item from the stack.
The value of popped item is stored in val. On success functions returns true, val contains value popped from the stack. If stack is empty the function returns false, val is unchanged.
|
inline |
Returns stack's item count.
The value returned depends on opt::item_counter option. For atomicity::empty_item_counter, this function always returns 0.
Warning: even if you use real item counter and it returns 0, this fact is not mean that the stack is empty. To check emptyness use empty() method.