/// Buffer type for internal array
/*
The type of element for the buffer is not important: the queue rebinds
- buffer for required type via \p rebind metafunction.
+ the buffer for required type via \p rebind metafunction.
For \p VyukovMPMCCycleQueue queue the buffer size should have power-of-2 size.
+
+ You should use only uninitialized buffer for the queue -
+ \p cds::opt::v::uninitialized_dynamic_buffer (the default),
+ \p cds::opt::v::uninitialized_static_buffer.
*/
- typedef cds::opt::v::dynamic_buffer< void * > buffer;
+ typedef cds::opt::v::uninitialized_dynamic_buffer< void * > buffer;
/// A functor to clean item dequeued.
/**
- The functor calls the destructor for queue item.
+ The functor calls the destructor for queue item.
After an item is dequeued, \p value_cleaner cleans the cell that the item has been occupied.
- If \p T is a complex type, \p value_cleaner may be the useful feature.
+ If \p T is a complex type, \p value_cleaner may be useful feature.
Default value is \ref opt::v::destruct_cleaner
*/
/// 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).
+ or \p opt::v::sequential_consistent (sequentially consistent memory model).
*/
typedef opt::v::relaxed_ordering memory_model;
/// Single-consumer version
/**
For single-consumer version of algorithm some additional functions
-
(\p front(), \p pop_front()) is available.
Default is \p false
/// Metafunction converting option list to \p vyukov_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::buffer - an uninitialized buffer type for internal cyclic array. Possible types are:
+ \p opt::v::uninitialized_dynamic_buffer (the default), \p opt::v::uninitialized_static_buffer. The type of
element in the buffer is not important: it will be changed via \p rebind metafunction.
- \p opt::value_cleaner - a functor to clean item dequeued.
The functor calls the destructor for queue item.
\code
typedef cds::container::VyukovMPMCCycleQueue< Foo,
typename cds::container::vyukov_queue::make_traits<
- cds::opt::buffer< cds::opt::v::static_buffer< void *, 1024 >,
+ cds::opt::buffer< cds::opt::v::uninitialized_static_buffer< void *, 1024 >,
cds::opt::item_counte< cds::atomicity::item_counter >
>::type
> myQueue;
Template parameters
- \p T - type stored in queue.
- - \p Traits - queue traits, default is \p vykov_queue::traits. You can use \p vykov_queue::make_traits
- metafunction to make your traits or just derive your traits from \p %vykov_queue::traits:
+ - \p Traits - queue traits, default is \p vyukov_queue::traits. You can use \p vyukov_queue::make_traits
+ metafunction to make your traits or just derive your traits from \p %vyukov_queue::traits:
\code
- struct myTraits: public cds::container::vykov_queue::traits {
+ struct myTraits: public cds::container::vyukov_queue::traits {
typedef cds::atomicity::item_counter item_counter;
};
typedef cds::container::VyukovMPMCCycleQueue< Foo, myTraits > myQueue;
// Equivalent make_traits example:
typedef cds::container::VyukovMPMCCycleQueue< cds::gc::HP, Foo,
- typename cds::container::vykov_queue::make_traits<
+ typename cds::container::vyukov_queue::make_traits<
cds::opt::item_counter< cds::atomicity::item_counter >
>::type
> myQueue;
typedef T value_type; ///< Value type to be stored in the queue
typedef Traits traits; ///< Queue traits
typedef typename traits::item_counter item_counter; ///< Item counter type
- typedef typename traits::memory_model memory_model; ///< Memory ordering. See cds::opt::memory_model option
+ typedef typename traits::memory_model memory_model; ///< Memory ordering. See \p cds::opt::memory_model option
typedef typename traits::value_cleaner value_cleaner; ///< Value cleaner, see \p vyukov_queue::traits::value_cleaner
typedef typename traits::back_off back_off; ///< back-off strategy
public:
/// Constructs the queue of capacity \p nCapacity
/**
- For \p cds::opt::v::static_buffer the \p nCapacity parameter is ignored.
+ For \p cds::opt::v::uninitialized_static_buffer the \p nCapacity parameter is ignored.
The buffer capacity must be the power of two.
*/
{
#if (CDS_COMPILER == CDS_COMPILER_GCC) && (CDS_COMPILER_VERSION < 40900)
//work around unsupported feature in g++ 4.8 for forwarding parameter packs to lambda.
- return enqueue_with ( std::bind([]( value_type& dest,Args ... args ){ new ( &dest ) value_type( std::forward<Args>(args)... );}, std::placeholders::_1 ,args...));
+ value_type val( std::forward<Args>(args)... );
+ return enqueue_with( [&val]( value_type& dest ){ new ( &dest ) value_type( std::move( val )); });
#else
- return enqueue_with( [&args ...]( value_type& dest ){ new ( &dest ) value_type( std::forward<Args>(args)... ); });
+ return enqueue_with( [&args ...]( value_type& dest ){ new ( &dest ) value_type( std::forward<Args>( args )... ); });
#endif
}
//@endcond
/// Vyukov's queue multiple producer - single consumer version
-
template <typename T, typename Traits = vyukov_queue::traits >
using VyukovMPSCCycleQueue = VyukovMPMCCycleQueue< T, vyukov_queue::single_consumer_traits<Traits> >;