typedef T value_type;
typedef Traits traits;
- /*
- struct default_options {
- typedef cds::backoff::empty back_off;
- typedef CDS_DEFAULT_ALLOCATOR allocator;
- typedef atomicity::empty_item_counter item_counter;
- typedef intrusive::optimistic_queue::dummy_stat stat;
- typedef opt::v::relaxed_ordering memory_model;
- enum { alignment = opt::cache_line_alignment };
- };
- */
-
struct node_type: public cds::intrusive::optimistic_queue::node< gc >
{
value_type m_value;
> myQueue;
\endcode
*/
- template <typename GC, typename T, typename Traits>
+ template <typename GC, typename T, typename Traits = optimistic_queue::traits >
class OptimisticQueue:
#ifdef CDS_DOXYGEN_INVOKED
private intrusive::OptimisticQueue< GC, cds::intrusive::optimistic_queue::node< T >, Traits >
*/
bool dequeue( value_type& dest )
{
- typedef cds::details::trivial_assign<value_type, value_type> functor;
return dequeue_with( [&dest]( value_type& src ) { dest = src; } );
}
- 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.
- opt::alignment - the alignment for internal queue data. Default is \p opt::cache_line_alignment
- - 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).
Example: declare mutex-based \p %RWQueue with item counting
\code
typedef typename traits::lock_type lock_type; ///< Locking primitive
typedef typename traits::item_counter item_counter; ///< Item counting policy used
- typedef typename traits::memory_model memory_model; ///< Memory ordering. See \p cds::opt::memory_model option
protected:
//@cond
bool enqueue( value_type const& data )
{
scoped_node_ptr p( alloc_node( data ));
- if ( enqueue_node( p )) {
+ if ( enqueue_node( p.get() )) {
p.release();
return true;
}
{
scoped_node_ptr p( alloc_node() );
f( p->m_value );
- if ( enqueue_node( p ) ) {
+ if ( enqueue_node( p.get() )) {
p.release();
return true;
}
*/
bool dequeue( value_type& dest )
{
- return dequeue( [&dest]( value_type * src ) { dest = src; } );
+ return dequeue_with( [&dest]( value_type& src ) { dest = src; } );
}
/// Dequeues a value using a functor
tests/test-hdr/queue/hdr_moirqueue_dhp.cpp \
tests/test-hdr/queue/hdr_msqueue_hp.cpp \
tests/test-hdr/queue/hdr_msqueue_dhp.cpp \
- tests/test-hdr/queue/hdr_optimistic_hzp.cpp \
- tests/test-hdr/queue/hdr_optimistic_ptb.cpp \
+ tests/test-hdr/queue/hdr_optimistic_hp.cpp \
+ tests/test-hdr/queue/hdr_optimistic_dhp.cpp \
tests/test-hdr/queue/hdr_rwqueue.cpp \
tests/test-hdr/queue/hdr_segmented_queue_hp.cpp \
tests/test-hdr/queue/hdr_segmented_queue_ptb.cpp \
// *********************************************
// Queue statistics
namespace std {
-
+ /*
// cds::intrusive::queue_stat
template <typename Counter>
static inline std::ostream& operator <<(std::ostream& o, cds::intrusive::queue_stat<Counter> const& s)
{
return o;
}
+ */
template <typename Counter>
static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::optimistic_queue::stat<Counter> const& s )
{
return o
- << static_cast<cds::intrusive::queue_stat<Counter> const&>( s )
- << "\t\t"
- << "\t\t fix list call: " << s.m_FixListCount.get() << "\n";
+ << "\tStatistics:\n"
+ << "\t\t Enqueue count: " << s.m_EnqueueCount.get() << "\n"
+ << "\t\t Enqueue race: " << s.m_EnqueueRace.get() << "\n"
+ << "\t\t Dequeue count: " << s.m_DequeueCount.get() << "\n"
+ << "\t\t Dequeue race: " << s.m_DequeueRace.get() << "\n"
+ << "\t\tAdvance tail error: " << s.m_AdvanceTailError.get() << "\n"
+ << "\t\t Bad tail: " << s.m_BadTail.get() << "\n"
+ << "\t\t fix list call: " << s.m_FixListCount.get() << "\n";
}
- static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::optimistic_queue::dummy_stat const& s )
+ static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::optimistic_queue::empty_stat const& s )
{
return o;
}
// OptimisticQueue
typedef cds::container::OptimisticQueue< cds::gc::HP, Value > OptimisticQueue_HP;
- typedef cds::container::OptimisticQueue< cds::gc::PTB, Value > OptimisticQueue_PTB;
+ typedef cds::container::OptimisticQueue< cds::gc::DHP, Value > OptimisticQueue_DHP;
struct traits_OptimisticQueue_michaelAlloc : public cds::container::optimistic_queue::traits
{
struct traits_OptimisticQueue_stat : public
cds::container::optimistic_queue::make_traits <
- cds::opt::stat < cds::intrusive::queue_stat<> >
+ cds::opt::stat < cds::intrusive::optimistic_queue::stat<> >
> ::type
{};
typedef cds::container::OptimisticQueue< cds::gc::HP, Value, traits_OptimisticQueue_stat > OptimisticQueue_HP_stat;
cds::opt::lock_type< std::mutex >
>::type
{};
- typedef cds::container::RWQueue< Value, traits_RWQueue_mutex > traits_RWQueue_mutex;
+ typedef cds::container::RWQueue< Value, traits_RWQueue_mutex > RWQueue_mutex;
// FCQueue
class traits_FCQueue_elimination:
// *********************************************
// Queue statistics
namespace std {
-
+ /*
template <typename Counter>
static inline std::ostream& operator <<(std::ostream& o, cds::intrusive::queue_stat<Counter> const& s)
{
{
return o;
}
+ */
template <typename Counter>
static inline std::ostream& operator <<(std::ostream& o, cds::container::basket_queue::stat<Counter> const& s)