buffer for required type via \p rebind metafunction.
For \p TsigasCycleQueue queue the buffer size should have power-of-2 size.
+
+ You should use any initialized buffer type, see \p opt::buffer.
*/
- typedef cds::opt::v::dynamic_buffer< void * > buffer;
+ typedef cds::opt::v::initialized_dynamic_buffer< void * > buffer;
/// Node allocator
typedef CDS_DEFAULT_ALLOCATOR allocator;
*/
typedef opt::v::relaxed_ordering memory_model;
- /// Alignment for internal queue data. Default is \p opt::cache_line_alignment
- enum { alignment = opt::cache_line_alignment };
+ /// Padding for internal critical atomic data. Default is \p opt::cache_line_padding
+ enum { padding = opt::cache_line_padding };
};
/// Metafunction converting option list to \p tsigas_queue::traits
/**
Supported \p Options are:
- \p opt::buffer - the buffer type for internal cyclic array. Possible types are:
- \p opt::v::dynamic_buffer (the default), \p opt::v::static_buffer. The type of
+ \p opt::v::initialized_dynamic_buffer (the default), \p opt::v::initialized_static_buffer. The type of
element in the buffer is not important: it will be changed via \p rebind metafunction.
- \p opt::allocator - allocator (like \p std::allocator) used for allocating queue items. Default is \ref CDS_DEFAULT_ALLOCATOR
- \p opt::back_off - back-off strategy used, default is \p cds::backoff::empty.
- \p opt::item_counter - the type of item counting feature. Default is \p cds::atomicity::empty_item_counter (item counting disabled)
To enable item counting use \p cds::atomicity::item_counter
- - \p opt::alignment - the alignment for internal queue data. Default is \p opt::cache_line_alignment
+ - \p opt::padding - padding for internal critical atomic data. Default is \p opt::cache_line_padding
- \p opt::memory_model - C++ memory ordering model. Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
or \p opt::v::sequential_consistent (sequentially consisnent memory model).
\code
typedef cds::container::TsigasCycleQueue< Foo,
typename cds::container::tsigas_queue::make_traits<
- cds::opt::buffer< cds::opt::v::static_buffer< void *, 1024 >,
- cds::opt::item_counte< cds::atomicity::item_counter >
+ cds::opt::buffer< cds::opt::v::initialized_static_buffer< void *, 1024 >,
+ cds::opt::item_counter< cds::atomicity::item_counter >
>::type
> myQueue;
\endcode
// Queue of Foo, capacity is 1024, statically allocated buffer:
typedef cds::container::TsigasCycleQueue< Foo,
typename cds::container::tsigas_queue::make_traits<
- cds::opt::buffer< cds::opt::v::static_buffer< Foo, 1024 > >
+ cds::opt::buffer< cds::opt::v::initialized_static_buffer< Foo, 1024 > >
>::type
> static_queue;
static_queue stQueue;
// Queue of Foo, capacity is 1024, dynamically allocated buffer:
typedef cds::container::TsigasCycleQueue< Foo
typename cds::container::tsigas_queue::make_traits<
- cds::opt::buffer< cds::opt::v::dynamic_buffer< Foo > >
+ cds::opt::buffer< cds::opt::v::initialized_dynamic_buffer< Foo > >
>::type
> dynamic_queue;
dynamic_queue dynQueue( 1024 );
public:
/// Initialize empty queue of capacity \p nCapacity
/**
- If internal buffer type is \p cds::opt::v::static_buffer, the \p nCapacity parameter is ignored.
+ If internal buffer type is \p cds::opt::v::initialized_static_buffer, the \p nCapacity parameter is ignored.
Note, the real capacity of queue is \p nCapacity - 2.
*/
return false;
}
+ /// Enqueues \p val value into the queue, move semantics
+ bool enqueue( value_type&& val )
+ {
+ scoped_node_ptr p( alloc_node_move( std::move( val )));
+ if ( base_class::enqueue( *p ) ) {
+ p.release();
+ return true;
+ }
+ return false;
+ }
+
/// Enqueues data to the queue using a functor
/**
\p Func is a functor called to create node.
return false;
}
- /// Synonym for template version of \p enqueue() function
+ /// Synonym for \p enqueue( value_type const& )
bool push( value_type const& data )
{
return enqueue( data );
}
+ /// Synonym for \p enqueue( value_type&& )
+ bool push( value_type&& data )
+ {
+ return enqueue( std::move( data ));
+ }
+
/// Synonym for \p enqueue_with() function
template <typename Func>
bool push_with( Func f )
*/
bool dequeue( value_type& dest )
{
- return dequeue_with( [&dest]( value_type& src ) { dest = src; } );
+ return dequeue_with( [&dest]( value_type& src ) { dest = std::move( src );});
}
/// Synonym for \p dequeue() function