#include <functional> // ref
#include <cds/intrusive/msqueue.h>
#include <cds/container/details/base.h>
-#include <cds/details/trivial_assign.h>
namespace cds { namespace container {
+ /// MSQueue related definitions
+ /** @ingroup cds_nonintrusive_helper
+ */
+ namespace msqueue {
+ /// Internal statistics
+ template <typename Counter = cds::intrusive::msqueue::stat<>::counter_type >
+ using stat = cds::intrusive::msqueue::stat< Counter >;
+
+ /// Dummy internal statistics
+ typedef cds::intrusive::msqueue::empty_stat empty_stat;
+
+ /// MSQueue default type traits
+ struct traits
+ {
+ /// Node allocator
+ typedef CDS_DEFAULT_ALLOCATOR allocator;
+
+ /// Back-off strategy
+ typedef cds::backoff::empty back_off;
+
+ /// Item counting feature; by default, disabled. Use \p cds::atomicity::item_counter to enable item counting
+ typedef atomicity::empty_item_counter item_counter;
+
+ /// Internal statistics (by default, disabled)
+ /**
+ Possible option value are: \p msqueue::stat, \p msqueue::empty_stat (the default),
+ user-provided class that supports \p %msqueue::stat interface.
+ */
+ typedef msqueue::empty_stat stat;
+
+ /// 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).
+ */
+ typedef opt::v::relaxed_ordering memory_model;
+
+ /// Alignment of internal queue data. Default is \p opt::cache_line_alignment
+ enum { alignment = opt::cache_line_alignment };
+ };
+
+ /// Metafunction converting option list to \p msqueue::traits
+ /**
+ This is a wrapper for <tt> cds::opt::make_options< type_traits, Options...> </tt>
+ Supported \p Options are:
+ - opt::allocator - allocator (like \p std::allocator) used for allocating queue nodes. Default is \ref CDS_DEFAULT_ALLOCATOR
+ - opt::back_off - back-off strategy used, default is \p cds::backoff::empty.
+ - 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::stat - the type to gather internal statistics.
+ Possible statistics types are: \p msqueue::stat, \p msqueue::empty_stat, user-provided class that supports \p %msqueue::stat interface.
+ Default is \p %msqueue::empty_stat.
+ - 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 \p %MSQueue with item counting and internal statistics
+ \code
+ typedef cds::container::MSQueue< cds::gc::HP, Foo,
+ typename cds::container::msqueue::make_traits<
+ cds::opt::item_counte< cds::atomicity::item_counter >,
+ cds::opt::stat< cds::intrusive::msqueue::stat<> >
+ >::type
+ > myQueue;
+ \endcode
+ */
+ template <typename... Options>
+ struct make_traits {
+# ifdef CDS_DOXYGEN_INVOKED
+ typedef implementation_defined type; ///< Metafunction result
+# else
+ typedef typename cds::opt::make_options<
+ typename cds::opt::find_type_traits< traits, Options... >::type
+ , Options...
+ >::type type;
+# endif
+ };
+ } // namespace msqueue
+
//@cond
namespace details {
- template <typename GC, typename T, typename... Options>
+ template <typename GC, typename T, typename Traits>
struct make_msqueue
{
typedef GC gc;
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::queue_dummy_stat stat;
- typedef opt::v::relaxed_ordering memory_model;
- enum { alignment = opt::cache_line_alignment };
- };
-
- typedef typename opt::make_options<
- typename cds::opt::find_type_traits< default_options, Options... >::type
- ,Options...
- >::type options;
-
- struct node_type: public intrusive::single_link::node< gc >
+ struct node_type: public intrusive::msqueue::node< gc >
{
value_type m_value;
- node_type( const value_type& val )
+
+ node_type( value_type const& val )
: m_value( val )
{}
{}
};
- typedef typename options::allocator::template rebind<node_type>::other allocator_type;
+ typedef typename traits::allocator::template rebind<node_type>::other allocator_type;
typedef cds::details::Allocator< node_type, allocator_type > cxx_allocator;
struct node_deallocator
}
};
- typedef intrusive::MSQueue< gc,
- node_type
- ,intrusive::opt::hook<
- intrusive::single_link::base_hook< opt::gc<gc> >
- >
- ,opt::back_off< typename options::back_off >
- ,intrusive::opt::disposer< node_deallocator >
- ,opt::item_counter< typename options::item_counter >
- ,opt::stat< typename options::stat >
- ,opt::alignment< options::alignment >
- ,opt::memory_model< typename options::memory_model >
- > type;
+ struct intrusive_traits : public traits
+ {
+ typedef cds::intrusive::base_hook< cds::opt::gc<gc> > hook;
+ typedef node_deallocator disposer;
+ };
+
+ typedef intrusive::MSQueue< gc, node_type, intrusive_traits > type;
};
}
//@endcond
/// Michael & Scott lock-free queue
/** @ingroup cds_nonintrusive_queue
It is non-intrusive version of Michael & Scott's queue algorithm based on intrusive implementation
- intrusive::MSQueue.
+ \p cds::intrusive::MSQueue.
Template arguments:
- - \p GC - garbage collector type: gc::HP, gc::HRC, gc::PTB
- - \p T is a type stored in the queue. It should be default-constructible, copy-constructible, assignable type.
- - \p Options - options
-
- Permissible \p Options:
- - opt::allocator - allocator (like \p std::allocator). Default is \ref CDS_DEFAULT_ALLOCATOR
- - opt::back_off - back-off strategy used. If the option is not specified, the cds::backoff::empty is used
- - opt::item_counter - the type of item counting feature. Default is \ref atomicity::empty_item_counter
- - opt::stat - the type to gather internal statistics.
- Possible option value are: intrusive::queue_stat, intrusive::queue_dummy_stat,
- user-provided class that supports intrusive::queue_stat interface.
- Default is \ref intrusive::queue_dummy_stat.
- - opt::alignment - the alignment for internal queue data. Default is opt::cache_line_alignment
- - opt::memory_model - C++ memory ordering model. Can be opt::v::relaxed_ordering (relaxed memory model, the default)
- or opt::v::sequential_consistent (sequentially consisnent memory model).
+ - \p GC - garbage collector type: \p gc::HP, \p gc::DHP
+ - \p T is a type stored in the queue.
+ - \p Traits - queue traits, default is \p msqueue::traits. You can use \p msqueue::make_traits
+ metafunction to make your traits or just derive your traits from \p %msqueue::traits:
+ \code
+ struct myTraits: public cds::container::msqueue::traits {
+ typedef cds::intrusive::msqueue::stat<> stat;
+ typedef cds::atomicity::item_counter item_counter;
+ };
+ typedef cds::container::MSQueue< cds::gc::HP, Foo, myTraits > myQueue;
+
+ // Equivalent make_traits example:
+ typedef cds::container::MSQueue< cds::gc::HP, Foo,
+ typename cds::container::msqueue::make_traits<
+ cds::opt::stat< cds::container::msqueue::stat<> >,
+ cds::opt::item_counter< cds::atomicity::item_counter >
+ >::type
+ > myQueue;
+ \endcode
*/
- template <typename GC, typename T, typename... Options>
+ template <typename GC, typename T, typename Traits>
class MSQueue:
#ifdef CDS_DOXYGEN_INVOKED
- intrusive::MSQueue< GC, intrusive::single_link::node< T >, Options... >
+ intrusive::MSQueue< GC, cds::intrusive::msqueue::node< T >, Traits >
#else
- details::make_msqueue< GC, T, Options... >::type
+ details::make_msqueue< GC, T, Traits >::type
#endif
{
//@cond
- typedef details::make_msqueue< GC, T, Options... > options;
- typedef typename options::type base_class;
+ typedef details::make_msqueue< GC, T, Traits > maker;
+ typedef typename maker::type base_class;
//@endcond
public:
/// Rebind template arguments
- template <typename GC2, typename T2, typename... Options2>
+ template <typename GC2, typename T2, typename Traits2>
struct rebind {
- typedef MSQueue< GC2, T2, Options2...> other ; ///< Rebinding result
+ typedef MSQueue< GC2, T2, Traits2> other ; ///< Rebinding result
};
public:
- typedef T value_type ; ///< Value type stored in the queue
-
- typedef typename base_class::gc gc ; ///< Garbage collector used
- typedef typename base_class::back_off back_off ; ///< Back-off strategy used
- typedef typename options::allocator_type allocator_type ; ///< Allocator type used for allocate/deallocate the nodes
- typedef typename base_class::item_counter item_counter ; ///< Item counting policy used
- typedef typename base_class::stat stat ; ///< Internal statistics policy used
- typedef typename base_class::memory_model memory_model ; ///< Memory ordering. See cds::opt::memory_model option
+ typedef T value_type; ///< Value type stored in the queue
+ typedef typename base_class::gc gc; ///< Garbage collector used
+ typedef typename base_class::back_off back_off; ///< Back-off strategy used
+ typedef typename maker::allocator_type allocator_type; ///< Allocator type used for allocate/deallocate the nodes
+ typedef typename base_class::item_counter item_counter; ///< Item counting policy used
+ typedef typename base_class::stat stat; ///< Internal statistics policy used
+ typedef typename base_class::memory_model memory_model; ///< Memory ordering. See cds::opt::memory_model option
protected:
- typedef typename options::node_type node_type ; ///< queue node type (derived from intrusive::single_link::node)
+ typedef typename maker::node_type node_type ; ///< queue node type (derived from \p intrusive::msqueue::node)
//@cond
- typedef typename options::cxx_allocator cxx_allocator;
- typedef typename options::node_deallocator node_deallocator; // deallocate node
+ typedef typename maker::cxx_allocator cxx_allocator;
+ typedef typename maker::node_deallocator node_deallocator; // deallocate node
typedef typename base_class::node_traits node_traits;
//@endcond
return false;
}
- /// Enqueues \p data to queue using copy functor
+ /// Enqueues \p data to queue using a functor
/**
- \p Func is a functor called to copy value \p data of type \p Type
- which may be differ from type \ref value_type stored in the queue.
- The functor's interface is:
+ \p Func is a functor called to create node.
+ The functor \p f takes one argument - a reference to a new node of type \ref value_type:
\code
- struct myFunctor {
- void operator()(value_type& dest, Type const& data)
- {
- // // Code to copy \p data to \p dest
- dest = data;
- }
- };
+ cds:container::MSQueue< cds::gc::HP, Foo > myQueue;
+ Bar bar;
+ myQueue.enqueue_with( [&bar]( Foo& dest ) { dest = bar; } );
\endcode
- You may use \p boost:ref construction to pass functor \p f by reference.
-
- <b>Requirements</b> The functor \p Func should not throw any exception.
*/
- template <typename Type, typename Func>
- bool enqueue( Type const& data, Func f )
+ template <typename Func>
+ bool enqueue_with( Func f )
{
scoped_node_ptr p( alloc_node() );
- f( p->m_value, data );
+ f( p->m_value );
if ( base_class::enqueue( *p )) {
p.release();
return true;
return false;
}
- /// Dequeues a value using copy functor
+ /// Enqueues data of type \ref value_type constructed from <tt>std::forward<Args>(args)...</tt>
+ template <typename... Args>
+ bool emplace( Args&&... args )
+ {
+ scoped_node_ptr p( alloc_node_move( std::forward<Args>( args )... ) );
+ if ( base_class::enqueue( *p ) ) {
+ p.release();
+ return true;
+ }
+ return false;
+ }
+
+ /// Synonym for \ref enqueue function
+ bool push( value_type const& val )
+ {
+ return enqueue( val );
+ }
+
+ /// Synonym for \p enqueue_with() function
+ template <typename Func>
+ bool push_with( Func f )
+ {
+ return enqueue_with( f );
+ }
+
+ /// Dequeues a value using a functor
/**
- \p Func is a functor called to copy dequeued value to \p dest of type \p Type
- which may be differ from type \ref value_type stored in the queue.
- The functor's interface is:
+ \p Func is a functor called to copy dequeued value.
+ The functor takes one argument - a reference to removed node:
\code
- struct myFunctor {
- void operator()(Type& dest, value_type const& data)
- {
- // Code to copy \p data to \p dest
- dest = data;
- }
- };
+ cds:container::MSQueue< cds::gc::HP, Foo > myQueue;
+ Bar bar;
+ myQueue.dequeue_with( [&bar]( Foo& src ) { bar = std::move( src );});
\endcode
- You may use \p boost:ref construction to pass functor \p f by reference.
-
- <b>Requirements</b> The functor \p Func should not throw any exception.
+ The functor is called only is the queue is not empty.
*/
- template <typename Type, typename Func>
- bool dequeue( Type& dest, Func f )
+ template <typename Func>
+ bool dequeue_with( Func f )
{
typename base_class::dequeue_result res;
if ( base_class::do_dequeue( res )) {
- f( dest, node_traits::to_value_ptr( *res.pNext )->m_value );
-
+ f( node_traits::to_value_ptr( *res.pNext )->m_value );
base_class::dispose_result( res );
-
return true;
}
return false;
return dequeue( dest, functor() );
}
- /// Synonym for \ref enqueue function
- bool push( value_type const& val )
- {
- return enqueue( val );
- }
-
- /// Synonym for template version of \ref enqueue function
- template <typename Type, typename Func>
- bool push( Type const& data, Func f )
- {
- return enqueue( data, f );
- }
-
/// Synonym for \ref dequeue function
bool pop( value_type& dest )
{
return dequeue( dest );
}
- /// Synonym for template version of \ref dequeue function
- template <typename Type, typename Func>
- bool pop( Type& dest, Func f )
+ /// Synonym for \p dequeue_with() function
+ template <typename Func>
+ bool pop_with( Func f )
{
- return dequeue( dest, f );
- }
-
- /// Enqueues data of type \ref value_type constructed with <tt>std::forward<Args>(args)...</tt>
- template <typename... Args>
- bool emplace( Args&&... args )
- {
- scoped_node_ptr p( alloc_node_move( std::forward<Args>(args)... ) );
- if ( base_class::enqueue( *p )) {
- p.release();
- return true;
- }
- return false;
+ return dequeue_with( f );
}
/// Checks if the queue is empty
typedef typename base_class::stat stat ; ///< Internal statistics policy used
protected:
- typedef typename maker::node_type node_type ; ///< stack node type (derived from intrusive::treiber_stack::node)
+ typedef typename maker::node_type node_type ; ///< stack node type (derived from \p intrusive::treiber_stack::node)
//@cond
typedef typename maker::cxx_allocator cxx_allocator;
This is slightly optimized Michael & Scott's queue algorithm that overloads \ref dequeue function.
Source:
- \li [2000] Simon Doherty, Lindsay Groves, Victor Luchangco, Mark Moir
+ - [2000] Simon Doherty, Lindsay Groves, Victor Luchangco, Mark Moir
"Formal Verification of a practical lock-free queue algorithm"
Cite from this work about difference from Michael & Scott algo:
frequently, our modification will reduce the number of accesses to global memory. This modification, however,
introduces the possibility of \p Head and \p Tail \93crossing\94."
- Type of node: \ref single_link::node
-
Explanation of template arguments see intrusive::MSQueue.
\par Examples
typedef cds::gc::HP hp_gc;
// MoirQueue with Hazard Pointer garbage collector, base hook + item disposer:
- struct Foo: public ci::single_link::node< hp_gc >
+ struct Foo: public ci::msqueue::node< hp_gc >
{
// Your data
...
typedef ci::MoirQueue<
hp_gc
,Foo
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<hp_gc> >
- >
- ,ci::opt::disposer< fooDisposer >
+ typename ci::msqueue::make_traits<
+ ,ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<hp_gc> >
+ >
+ ,ci::opt::disposer< fooDisposer >
+ >::type
> fooQueue;
// MoirQueue with Hazard Pointer garbage collector,
{
// Your data
...
- ci::single_link::node< hp_gc > hMember;
+ ci::msqueue::node< hp_gc > hMember;
};
- typedef ci::MoirQueue<
- hp_gc
- ,Foo
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(Bar, hMember)
- ,ci::opt::gc<hp_gc>
- >
- >
- ,ci::opt::disposer< fooDisposer >
- ,cds::opt::item_counter< cds::atomicity::item_counter >
- ,cds::opt::alignment< cds::opt::no_special_alignment >
- > barQueue;
-
+ struct barQueueTraits: public ci::msqueue::traits
+ {
+ typedef ci::msqueue::member_hook< offsetof(Bar, hMember), ,ci::opt::gc<hp_gc> > hook;
+ typedef fooDisposer disposer;
+ typedef cds::atomicity::item_counter item_counter;
+ enum { aligment = cds::opt::no_special_alignment alignment };
+ };
+ typedef ci::MoirQueue< hp_gc, Bar, barQueueTraits > barQueue;
\endcode
*/
- template <typename GC, typename T, typename... Options>
- class MoirQueue: public MSQueue< GC, T, Options... >
+ template <typename GC, typename T, typename Traits = cds::intrusive::msqueue::traits>
+ class MoirQueue: public MSQueue< GC, T, Traits >
{
//@cond
- typedef MSQueue< GC, T, Options... > base_class;
+ typedef MSQueue< GC, T, Traits > base_class;
typedef typename base_class::node_type node_type;
//@endcond
//@endcond
/// Rebind template arguments
- template <typename GC2, typename T2, typename... Options2>
+ template < typename GC2, typename T2, typename Traits2 >
struct rebind {
- typedef MoirQueue< GC2, T2, Options2...> other ; ///< Rebinding result
+ typedef MoirQueue< GC2, T2, Traits2> other ; ///< Rebinding result
};
protected:
public:
/// Dequeues a value from the queue
/** @anchor cds_intrusive_MoirQueue_dequeue
- See warning about item disposing in \ref MSQueue::dequeue.
+ See warning about item disposing in \p MSQueue::dequeue.
*/
value_type * dequeue()
{
To enable item counting use \p cds::atomicity::item_counter
- opt::stat - the type to gather internal statistics.
Possible statistics types are: \p msqueue::stat, \p msqueue::empty_stat, user-provided class that supports \p %msqueue::stat interface.
- Default is \p msqueue::empty_stat.
+ Default is \p %msqueue::empty_stat.
- 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).
\code
typedef cds::intrusive::MSQueue< cds::gc::HP, Foo,
typename cds::intrusive::msqueue::make_traits<
+ cds::intrusive::opt:hook< cds::intrusive::msqueue::base_hook< cds::opt::gc<cds:gc::HP> >>,
cds::opt::item_counte< cds::atomicity::item_counter >,
cds::opt::stat< cds::intrusive::msqueue::stat<> >
>::type
- \p T - type to be stored in the queue. A value of type \p T must be derived from \p msqueue::node for \p msqueue::base_hook,
or it should have a member of type \p %msqueue::node for \p msqueue::member_hook,
or it should be convertible to \p %msqueue::node for \p msqueue::traits_hook.
- - \p Traits - queue traits, default is \p queue::traits. You can use \p queue::make_traits
- metafunction to make your traits or just derive your traits from \p %queue::traits:
+ - \p Traits - queue traits, default is \p msqueue::traits. You can use \p msqueue::make_traits
+ metafunction to make your traits or just derive your traits from \p %msqueue::traits:
\code
- struct myTraits: public cds::intrusive::queue::traits {
+ struct myTraits: public cds::intrusive::msqueue::traits {
typedef cds::intrusive::msqueue::stat<> stat;
typedef cds::atomicity::item_counter item_counter;
};
typedef intrusive::node_to_value<MSQueue> node_to_value;
typedef typename opt::details::alignment_setter< typename node_type::atomic_node_ptr, traits::alignment >::type aligned_node_ptr;
-
typedef typename opt::details::alignment_setter< node_type, traits::alignment >::type dummy_node_type;
- aligned_node_ptr m_pHead ; ///< Queue's head pointer (cache-line aligned)
- aligned_node_ptr m_pTail ; ///< Queue's tail pointer (cache-line aligned)
+ aligned_node_ptr m_pHead ; ///< Queue's head pointer
+ aligned_node_ptr m_pTail ; ///< Queue's tail pointer
dummy_node_type m_Dummy ; ///< dummy node
item_counter m_ItemCounter ; ///< Item counter
stat m_Stat ; ///< Internal statistics
void dispose_node( node_type * p )
{
- // Note for he dummy node:
+ // Note about the dummy node:
// We cannot clear m_Dummy here since it leads to ABA.
// On the other hand, we cannot use deferred clear_links( &m_Dummy ) call via
// HP retiring cycle since m_Dummy is member of MSQueue and may be destroyed
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_basketqueue_hp.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_basketqueue_hrc.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_basketqueue_ptb.cpp" />\r
+ <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_moirqueue_dhp.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_moirqueue_hp.cpp" />\r
- <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_moirqueue_hrc.cpp" />\r
- <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_moirqueue_ptb.cpp" />\r
+ <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_msqueue_dhp.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_msqueue_hp.cpp" />\r
- <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_msqueue_hrc.cpp" />\r
- <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_msqueue_ptb.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_optimisticqueue_hp.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_optimisticqueue_ptb.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_segmented_queue_hp.cpp" />\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_moirqueue_hp.cpp">\r
<Filter>intrusive</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_moirqueue_hrc.cpp">\r
- <Filter>intrusive</Filter>\r
- </ClCompile>\r
- <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_moirqueue_ptb.cpp">\r
- <Filter>intrusive</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_msqueue_hp.cpp">\r
<Filter>intrusive</Filter>\r
</ClCompile>\r
- <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_msqueue_hrc.cpp">\r
- <Filter>intrusive</Filter>\r
- </ClCompile>\r
- <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_msqueue_ptb.cpp">\r
- <Filter>intrusive</Filter>\r
- </ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_optimisticqueue_hp.cpp">\r
<Filter>intrusive</Filter>\r
</ClCompile>\r
<ClCompile Include="..\..\..\tests\test-hdr\queue\queue_test_header.cpp">\r
<Filter>container</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_moirqueue_dhp.cpp">\r
+ <Filter>intrusive</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_msqueue_dhp.cpp">\r
+ <Filter>intrusive</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="..\..\..\tests\test-hdr\queue\hdr_intrusive_basketqueue_node.h">\r
CDS_TESTHDR_QUEUE := \
tests/test-hdr/queue/hdr_intrusive_basketqueue_hrc.cpp \
tests/test-hdr/queue/hdr_intrusive_fcqueue.cpp \
- tests/test-hdr/queue/hdr_intrusive_moirqueue_hrc.cpp \
- tests/test-hdr/queue/hdr_intrusive_msqueue_hrc.cpp \
tests/test-hdr/queue/hdr_intrusive_segmented_queue_hp.cpp \
tests/test-hdr/queue/hdr_intrusive_segmented_queue_ptb.cpp \
tests/test-hdr/queue/hdr_intrusive_tsigas_cycle_queue.cpp \
tests/test-hdr/queue/hdr_basketqueue_hzp.cpp \
tests/test-hdr/queue/hdr_basketqueue_ptb.cpp \
tests/test-hdr/queue/hdr_fcqueue.cpp \
- tests/test-hdr/queue/hdr_moirqueue_hrc.cpp \
tests/test-hdr/queue/hdr_moirqueue_hzp.cpp \
tests/test-hdr/queue/hdr_moirqueue_ptb.cpp \
- tests/test-hdr/queue/hdr_msqueue_hrc.cpp \
tests/test-hdr/queue/hdr_msqueue_hzp.cpp \
tests/test-hdr/queue/hdr_msqueue_ptb.cpp \
tests/test-hdr/queue/hdr_optimistic_hzp.cpp \
tests/test-hdr/queue/hdr_intrusive_basketqueue_hp.cpp \
tests/test-hdr/queue/hdr_intrusive_basketqueue_ptb.cpp \
tests/test-hdr/queue/hdr_intrusive_moirqueue_hp.cpp \
- tests/test-hdr/queue/hdr_intrusive_moirqueue_ptb.cpp \
+ tests/test-hdr/queue/hdr_intrusive_moirqueue_dhp.cpp \
tests/test-hdr/queue/hdr_intrusive_msqueue_hp.cpp \
- tests/test-hdr/queue/hdr_intrusive_msqueue_ptb.cpp \
+ tests/test-hdr/queue/hdr_intrusive_msqueue_dhp.cpp \
tests/test-hdr/queue/hdr_intrusive_optimisticqueue_hp.cpp \
tests/test-hdr/queue/hdr_intrusive_optimisticqueue_ptb.cpp
--- /dev/null
+//$$CDS-header$$
+
+#include "hdr_intrusive_msqueue.h"
+#include <cds/intrusive/moir_queue.h>
+#include <cds/gc/dhp.h>
+
+namespace queue {
+
+#define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
+
+ namespace {
+ typedef IntrusiveQueueHeaderTest::base_hook_item< ci::msqueue::node<cds::gc::DHP > > base_item_type;
+ typedef IntrusiveQueueHeaderTest::member_hook_item< ci::msqueue::node<cds::gc::DHP > > member_item_type;
+
+ // DHP base hook
+ typedef ci::MoirQueue< cds::gc::DHP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
+ > MoirQueue_DHP_base;
+
+ // DHP member hook
+ typedef ci::MoirQueue< cds::gc::DHP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::DHP>
+ >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
+ > MoirQueue_DHP_member;
+
+ /// DHP base hook + item counter
+ typedef ci::MoirQueue< cds::gc::DHP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> >
+ >
+ , co::item_counter< cds::atomicity::item_counter >
+ , co::memory_model< co::v::relaxed_ordering >
+ >::type
+ > MoirQueue_DHP_base_ic;
+
+ // DHP member hook + item counter
+ typedef ci::MoirQueue< cds::gc::DHP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::DHP>
+ >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , co::item_counter< cds::atomicity::item_counter >
+ >::type
+ > MoirQueue_DHP_member_ic;
+
+ // DHP base hook + stat
+ typedef ci::MoirQueue< cds::gc::DHP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , co::stat< ci::msqueue::stat<> >
+ >::type
+ > MoirQueue_DHP_base_stat;
+
+ // DHP member hook + stat
+ typedef ci::MoirQueue< cds::gc::DHP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::DHP>
+ >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , co::stat< ci::msqueue::stat<> >
+ >::type
+ > MoirQueue_DHP_member_stat;
+
+ // DHP base hook + alignment
+ typedef ci::MoirQueue< cds::gc::DHP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> >
+ >
+ , co::alignment< 32 >
+ >::type
+ > MoirQueue_DHP_base_align;
+
+ // DHP member hook + alignment
+ typedef ci::MoirQueue< cds::gc::DHP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::DHP>
+ >
+ >
+ , co::alignment< 32 >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
+ > MoirQueue_DHP_member_align;
+
+ // DHP base hook + no alignment
+ struct traits_MoirQueue_DHP_base_noalign : public ci::msqueue::traits {
+ typedef ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> > hook;
+ typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
+ enum { alignment = co::no_special_alignment };
+ };
+ typedef ci::MoirQueue< cds::gc::DHP, base_item_type, traits_MoirQueue_DHP_base_noalign > MoirQueue_DHP_base_noalign;
+
+ // DHP member hook + no alignment
+ struct traits_MoirQueue_DHP_member_noalign : public ci::msqueue::traits {
+ typedef ci::msqueue::member_hook <
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc < cds::gc::DHP >
+ > hook;
+ typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
+ enum { alignment = co::no_special_alignment };
+ };
+ typedef ci::MoirQueue< cds::gc::DHP, member_item_type, traits_MoirQueue_DHP_member_noalign > MoirQueue_DHP_member_noalign;
+
+
+ // DHP base hook + cache alignment
+ struct traits_MoirQueue_DHP_base_cachealign : public traits_MoirQueue_DHP_base_noalign
+ {
+ enum { alignment = co::cache_line_alignment };
+ };
+ typedef ci::MoirQueue< cds::gc::DHP, base_item_type, traits_MoirQueue_DHP_base_cachealign > MoirQueue_DHP_base_cachealign;
+
+ // DHP member hook + cache alignment
+ struct traits_MoirQueue_DHP_member_cachealign : public traits_MoirQueue_DHP_member_noalign
+ {
+ enum { alignment = co::cache_line_alignment };
+ };
+ typedef ci::MoirQueue< cds::gc::DHP, member_item_type, traits_MoirQueue_DHP_member_cachealign > MoirQueue_DHP_member_cachealign;
+ } // namespace
+
+ TEST(MoirQueue_DHP_base)
+ TEST(MoirQueue_DHP_member)
+ TEST(MoirQueue_DHP_base_ic)
+ TEST(MoirQueue_DHP_member_ic)
+ TEST(MoirQueue_DHP_base_stat)
+ TEST(MoirQueue_DHP_member_stat)
+ TEST(MoirQueue_DHP_base_align)
+ TEST(MoirQueue_DHP_member_align)
+ TEST(MoirQueue_DHP_base_noalign)
+ TEST(MoirQueue_DHP_member_noalign)
+ TEST(MoirQueue_DHP_base_cachealign)
+ TEST(MoirQueue_DHP_member_cachealign)
+
+} // namespace queue
//$$CDS-header$$
#include "hdr_intrusive_msqueue.h"
-#include "hdr_intrusive_singlelink_node.h"
#include <cds/intrusive/moir_queue.h>
#include <cds/gc/hp.h>
#define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
namespace {
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ typedef IntrusiveQueueHeaderTest::base_hook_item< ci::msqueue::node<cds::gc::HP > > base_item_type;
+ typedef IntrusiveQueueHeaderTest::member_hook_item< ci::msqueue::node<cds::gc::HP > > member_item_type;
+
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
> MoirQueue_HP_default;
- /// cds::gc::HP + item counter
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::item_counter< cds::atomicity::item_counter >
+ /// HP + item counter
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::item_counter< cds::atomicity::item_counter >
+ ,co::memory_model< co::v::sequential_consistent >
+ >::type
> MoirQueue_HP_default_ic;
- /// cds::gc::HP + stat
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
+ /// HP + stat
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::stat< ci::msqueue::stat<> >
+ >::type
> MoirQueue_HP_default_stat;
- // cds::gc::HP base hook
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ // HP base hook
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
+ >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
> MoirQueue_HP_base;
- // cds::gc::HP member hook
- typedef ci::MoirQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
+ // HP member hook
+ typedef ci::MoirQueue< cds::gc::HP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::HP>
+ >
>
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
> MoirQueue_HP_member;
- /// cds::gc::HP base hook + item counter
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,co::item_counter< cds::atomicity::item_counter >
+ /// HP base hook + item counter
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
+ >
+ ,co::item_counter< cds::atomicity::item_counter >
+ ,co::memory_model< co::v::relaxed_ordering >
+ >::type
> MoirQueue_HP_base_ic;
- // cds::gc::HP member hook + item counter
- typedef ci::MoirQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
+ // HP member hook + item counter
+ typedef ci::MoirQueue< cds::gc::HP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::HP>
+ >
>
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::item_counter< cds::atomicity::item_counter >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::item_counter< cds::atomicity::item_counter >
+ >::type
> MoirQueue_HP_member_ic;
- // cds::gc::HP base hook + stat
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
+ // HP base hook + stat
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
+ >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::stat< ci::msqueue::stat<> >
+ >::type
> MoirQueue_HP_base_stat;
- // cds::gc::HP member hook + stat
- typedef ci::MoirQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
+ // HP member hook + stat
+ typedef ci::MoirQueue< cds::gc::HP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::HP>
+ >
>
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::stat< ci::msqueue::stat<> >
+ >::type
> MoirQueue_HP_member_stat;
- // cds::gc::HP base hook + alignment
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,co::alignment< 32 >
+ // HP base hook + alignment
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
+ >
+ ,co::alignment< 32 >
+ >::type
> MoirQueue_HP_base_align;
- // cds::gc::HP member hook + alignment
- typedef ci::MoirQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
+ // HP member hook + alignment
+ typedef ci::MoirQueue< cds::gc::HP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::HP>
+ >
>
- >
- ,co::alignment< 32 >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::alignment< 32 >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
> MoirQueue_HP_member_align;
- // cds::gc::HP base hook + no alignment
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::alignment< co::no_special_alignment >
- > MoirQueue_HP_base_noalign;
-
- // cds::gc::HP member hook + no alignment
- typedef ci::MoirQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
- >
- >
- ,co::alignment< co::no_special_alignment >
- > MoirQueue_HP_member_noalign;
-
-
- // cds::gc::HP base hook + cache alignment
- typedef ci::MoirQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,co::alignment< co::cache_line_alignment >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MoirQueue_HP_base_cachealign;
-
- // cds::gc::HP member hook + cache alignment
- typedef ci::MoirQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
- >
- >
- ,co::alignment< co::cache_line_alignment >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MoirQueue_HP_member_cachealign;
-
+ // HP base hook + no alignment
+ struct traits_MoirQueue_HP_base_noalign : public ci::msqueue::traits {
+ typedef ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> > hook;
+ typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
+ enum { alignment = co::no_special_alignment };
+ };
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type, traits_MoirQueue_HP_base_noalign > MoirQueue_HP_base_noalign;
+
+ // HP member hook + no alignment
+ struct traits_MoirQueue_HP_member_noalign : public ci::msqueue::traits {
+ typedef ci::msqueue::member_hook <
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc < cds::gc::HP >
+ > hook;
+ typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
+ enum { alignment = co::no_special_alignment };
+ };
+ typedef ci::MoirQueue< cds::gc::HP, member_item_type, traits_MoirQueue_HP_member_noalign > MoirQueue_HP_member_noalign;
+
+
+ // HP base hook + cache alignment
+ struct traits_MoirQueue_HP_base_cachealign : public traits_MoirQueue_HP_base_noalign
+ {
+ enum { alignment = co::cache_line_alignment };
+ };
+ typedef ci::MoirQueue< cds::gc::HP, base_item_type, traits_MoirQueue_HP_base_cachealign > MoirQueue_HP_base_cachealign;
+
+ // HP member hook + cache alignment
+ struct traits_MoirQueue_HP_member_cachealign : public traits_MoirQueue_HP_member_noalign
+ {
+ enum { alignment = co::cache_line_alignment };
+ };
+ typedef ci::MoirQueue< cds::gc::HP, member_item_type, traits_MoirQueue_HP_member_cachealign > MoirQueue_HP_member_cachealign;
}
TEST(MoirQueue_HP_default)
+++ /dev/null
-//$$CDS-header$$
-
-#include "hdr_intrusive_msqueue.h"
-#include "hdr_intrusive_singlelink_node.h"
-#include <cds/intrusive/moir_queue.h>
-#include <cds/gc/hrc.h>
-
-namespace queue {
-
-#define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
-
- namespace {
-
- // HRC base hook
- typedef ci::MoirQueue< cds::gc::HRC,
- base_hook_item<cds::gc::HRC>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HRC> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MoirQueue_HRC_base;
-
- // HRC base hook + item counter
- typedef ci::MoirQueue< cds::gc::HRC,
- base_hook_item<cds::gc::HRC>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HRC> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::item_counter< cds::atomicity::item_counter >
- > MoirQueue_HRC_base_ic;
-
- // HRC base hook + stat
- typedef ci::MoirQueue< cds::gc::HRC,
- base_hook_item<cds::gc::HRC>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HRC> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
- > MoirQueue_HRC_base_stat;
-
- // HRC base hook + alignment
- typedef ci::MoirQueue< cds::gc::HRC,
- base_hook_item<cds::gc::HRC>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HRC> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::alignment< 128 >
- > MoirQueue_HRC_base_align;
- }
-
- TEST(MoirQueue_HRC_base)
- TEST(MoirQueue_HRC_base_ic)
- TEST(MoirQueue_HRC_base_stat)
- TEST(MoirQueue_HRC_base_align)
-
-} // namespace queue
+++ /dev/null
-//$$CDS-header$$
-
-#include "hdr_intrusive_msqueue.h"
-#include "hdr_intrusive_singlelink_node.h"
-#include <cds/intrusive/moir_queue.h>
-#include <cds/gc/ptb.h>
-
-namespace queue {
-
-#define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
-
- namespace {
-
- // PTB base hook
- typedef ci::MoirQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MoirQueue_PTB_base;
-
- // PTB member hook
- typedef ci::MoirQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MoirQueue_PTB_member;
-
- /// PTB base hook + item counter
- typedef ci::MoirQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,co::item_counter< cds::atomicity::item_counter >
- ,co::memory_model< co::v::sequential_consistent >
- > MoirQueue_PTB_base_ic;
-
- // PTB member hook + item counter
- typedef ci::MoirQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::item_counter< cds::atomicity::item_counter >
- > MoirQueue_PTB_member_ic;
-
- // PTB base hook + stat
- typedef ci::MoirQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
- > MoirQueue_PTB_base_stat;
-
- // PTB member hook + stat
- typedef ci::MoirQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
- ,co::memory_model< co::v::relaxed_ordering >
- > MoirQueue_PTB_member_stat;
-
- // PTB base hook + alignment
- typedef ci::MoirQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,co::alignment< 32 >
- > MoirQueue_PTB_base_align;
-
- // PTB member hook + alignment
- typedef ci::MoirQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,co::alignment< 32 >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MoirQueue_PTB_member_align;
-
- // PTB base hook + no alignment
- typedef ci::MoirQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::alignment< co::no_special_alignment >
- > MoirQueue_PTB_base_noalign;
-
- // PTB member hook + no alignment
- typedef ci::MoirQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,co::alignment< co::no_special_alignment >
- > MoirQueue_PTB_member_noalign;
-
-
- // PTB base hook + cache alignment
- typedef ci::MoirQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,co::alignment< co::cache_line_alignment >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MoirQueue_PTB_base_cachealign;
-
- // PTB member hook + cache alignment
- typedef ci::MoirQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,co::alignment< co::cache_line_alignment >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MoirQueue_PTB_member_cachealign;
-
- } // namespace
-
- TEST(MoirQueue_PTB_base)
- TEST(MoirQueue_PTB_member)
- TEST(MoirQueue_PTB_base_ic)
- TEST(MoirQueue_PTB_member_ic)
- TEST(MoirQueue_PTB_base_stat)
- TEST(MoirQueue_PTB_member_stat)
- TEST(MoirQueue_PTB_base_align)
- TEST(MoirQueue_PTB_member_align)
- TEST(MoirQueue_PTB_base_noalign)
- TEST(MoirQueue_PTB_member_noalign)
- TEST(MoirQueue_PTB_base_cachealign)
- TEST(MoirQueue_PTB_member_cachealign)
-
-} // namespace queue
{
public:
+ template <typename Base>
+ struct base_hook_item : public Base
+ {
+ int nVal;
+ int nDisposeCount;
+
+ base_hook_item()
+ : nDisposeCount( 0 )
+ {}
+ };
+
+ template <typename Member>
+ struct member_hook_item
+ {
+ int nVal;
+ int nDisposeCount;
+ Member hMember;
+
+ member_hook_item()
+ : nDisposeCount( 0 )
+ {}
+ };
+
struct faked_disposer
{
template <typename T>
void test_MSQueue_HP_member_noalign();
void test_MSQueue_HP_base_cachealign();
void test_MSQueue_HP_member_cachealign();
- void test_MSQueue_HRC_base();
- void test_MSQueue_HRC_base_ic();
- void test_MSQueue_HRC_base_stat();
- void test_MSQueue_HRC_base_align();
- void test_MSQueue_PTB_base();
- void test_MSQueue_PTB_member();
- void test_MSQueue_PTB_base_ic();
- void test_MSQueue_PTB_member_ic();
- void test_MSQueue_PTB_base_stat();
- void test_MSQueue_PTB_member_stat();
- void test_MSQueue_PTB_base_align();
- void test_MSQueue_PTB_member_align();
- void test_MSQueue_PTB_base_noalign();
- void test_MSQueue_PTB_member_noalign();
- void test_MSQueue_PTB_base_cachealign();
- void test_MSQueue_PTB_member_cachealign();
+ void test_MSQueue_DHP_base();
+ void test_MSQueue_DHP_member();
+ void test_MSQueue_DHP_base_ic();
+ void test_MSQueue_DHP_member_ic();
+ void test_MSQueue_DHP_base_stat();
+ void test_MSQueue_DHP_member_stat();
+ void test_MSQueue_DHP_base_align();
+ void test_MSQueue_DHP_member_align();
+ void test_MSQueue_DHP_base_noalign();
+ void test_MSQueue_DHP_member_noalign();
+ void test_MSQueue_DHP_base_cachealign();
+ void test_MSQueue_DHP_member_cachealign();
void test_MoirQueue_HP_default();
void test_MoirQueue_HP_default_ic();
void test_MoirQueue_HP_member_noalign();
void test_MoirQueue_HP_base_cachealign();
void test_MoirQueue_HP_member_cachealign();
- void test_MoirQueue_HRC_base();
- void test_MoirQueue_HRC_base_ic();
- void test_MoirQueue_HRC_base_stat();
- void test_MoirQueue_HRC_base_align();
- void test_MoirQueue_PTB_base();
- void test_MoirQueue_PTB_member();
- void test_MoirQueue_PTB_base_ic();
- void test_MoirQueue_PTB_member_ic();
- void test_MoirQueue_PTB_base_stat();
- void test_MoirQueue_PTB_member_stat();
- void test_MoirQueue_PTB_base_align();
- void test_MoirQueue_PTB_member_align();
- void test_MoirQueue_PTB_base_noalign();
- void test_MoirQueue_PTB_member_noalign();
- void test_MoirQueue_PTB_base_cachealign();
- void test_MoirQueue_PTB_member_cachealign();
+ void test_MoirQueue_DHP_base();
+ void test_MoirQueue_DHP_member();
+ void test_MoirQueue_DHP_base_ic();
+ void test_MoirQueue_DHP_member_ic();
+ void test_MoirQueue_DHP_base_stat();
+ void test_MoirQueue_DHP_member_stat();
+ void test_MoirQueue_DHP_base_align();
+ void test_MoirQueue_DHP_member_align();
+ void test_MoirQueue_DHP_base_noalign();
+ void test_MoirQueue_DHP_member_noalign();
+ void test_MoirQueue_DHP_base_cachealign();
+ void test_MoirQueue_DHP_member_cachealign();
void test_OptimisticQueue_HP_default();
void test_OptimisticQueue_HP_default_ic();
CPPUNIT_TEST(test_MSQueue_HP_member_noalign)
CPPUNIT_TEST(test_MSQueue_HP_base_cachealign)
CPPUNIT_TEST(test_MSQueue_HP_member_cachealign)
- CPPUNIT_TEST(test_MSQueue_HRC_base)
- CPPUNIT_TEST(test_MSQueue_HRC_base_ic)
- CPPUNIT_TEST(test_MSQueue_HRC_base_stat)
- CPPUNIT_TEST(test_MSQueue_HRC_base_align)
- CPPUNIT_TEST(test_MSQueue_PTB_base)
- CPPUNIT_TEST(test_MSQueue_PTB_member)
- CPPUNIT_TEST(test_MSQueue_PTB_base_ic)
- CPPUNIT_TEST(test_MSQueue_PTB_member_ic)
- CPPUNIT_TEST(test_MSQueue_PTB_base_stat)
- CPPUNIT_TEST(test_MSQueue_PTB_member_stat)
- CPPUNIT_TEST(test_MSQueue_PTB_base_align)
- CPPUNIT_TEST(test_MSQueue_PTB_member_align)
- CPPUNIT_TEST(test_MSQueue_PTB_base_noalign)
- CPPUNIT_TEST(test_MSQueue_PTB_member_noalign)
- CPPUNIT_TEST(test_MSQueue_PTB_base_cachealign)
- CPPUNIT_TEST(test_MSQueue_PTB_member_cachealign)
+ CPPUNIT_TEST(test_MSQueue_DHP_base)
+ CPPUNIT_TEST(test_MSQueue_DHP_member)
+ CPPUNIT_TEST(test_MSQueue_DHP_base_ic)
+ CPPUNIT_TEST(test_MSQueue_DHP_member_ic)
+ CPPUNIT_TEST(test_MSQueue_DHP_base_stat)
+ CPPUNIT_TEST(test_MSQueue_DHP_member_stat)
+ CPPUNIT_TEST(test_MSQueue_DHP_base_align)
+ CPPUNIT_TEST(test_MSQueue_DHP_member_align)
+ CPPUNIT_TEST(test_MSQueue_DHP_base_noalign)
+ CPPUNIT_TEST(test_MSQueue_DHP_member_noalign)
+ CPPUNIT_TEST(test_MSQueue_DHP_base_cachealign)
+ CPPUNIT_TEST(test_MSQueue_DHP_member_cachealign)
CPPUNIT_TEST(test_MoirQueue_HP_default)
CPPUNIT_TEST(test_MoirQueue_HP_default_ic)
CPPUNIT_TEST(test_MoirQueue_HP_member_noalign)
CPPUNIT_TEST(test_MoirQueue_HP_base_cachealign)
CPPUNIT_TEST(test_MoirQueue_HP_member_cachealign)
- CPPUNIT_TEST(test_MoirQueue_HRC_base)
- CPPUNIT_TEST(test_MoirQueue_HRC_base_ic)
- CPPUNIT_TEST(test_MoirQueue_HRC_base_stat)
- CPPUNIT_TEST(test_MoirQueue_HRC_base_align)
- CPPUNIT_TEST(test_MoirQueue_PTB_base)
- CPPUNIT_TEST(test_MoirQueue_PTB_member)
- CPPUNIT_TEST(test_MoirQueue_PTB_base_ic)
- CPPUNIT_TEST(test_MoirQueue_PTB_member_ic)
- CPPUNIT_TEST(test_MoirQueue_PTB_base_stat)
- CPPUNIT_TEST(test_MoirQueue_PTB_member_stat)
- CPPUNIT_TEST(test_MoirQueue_PTB_base_align)
- CPPUNIT_TEST(test_MoirQueue_PTB_member_align)
- CPPUNIT_TEST(test_MoirQueue_PTB_base_noalign)
- CPPUNIT_TEST(test_MoirQueue_PTB_member_noalign)
- CPPUNIT_TEST(test_MoirQueue_PTB_base_cachealign)
- CPPUNIT_TEST(test_MoirQueue_PTB_member_cachealign)
+ CPPUNIT_TEST(test_MoirQueue_DHP_base)
+ CPPUNIT_TEST(test_MoirQueue_DHP_member)
+ CPPUNIT_TEST(test_MoirQueue_DHP_base_ic)
+ CPPUNIT_TEST(test_MoirQueue_DHP_member_ic)
+ CPPUNIT_TEST(test_MoirQueue_DHP_base_stat)
+ CPPUNIT_TEST(test_MoirQueue_DHP_member_stat)
+ CPPUNIT_TEST(test_MoirQueue_DHP_base_align)
+ CPPUNIT_TEST(test_MoirQueue_DHP_member_align)
+ CPPUNIT_TEST(test_MoirQueue_DHP_base_noalign)
+ CPPUNIT_TEST(test_MoirQueue_DHP_member_noalign)
+ CPPUNIT_TEST(test_MoirQueue_DHP_base_cachealign)
+ CPPUNIT_TEST(test_MoirQueue_DHP_member_cachealign)
CPPUNIT_TEST(test_OptimisticQueue_HP_default)
CPPUNIT_TEST(test_OptimisticQueue_HP_default_ic)
--- /dev/null
+//$$CDS-header$$
+
+#include "hdr_intrusive_msqueue.h"
+#include <cds/intrusive/msqueue.h>
+#include <cds/gc/dhp.h>
+
+namespace queue {
+
+#define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
+
+ namespace {
+ typedef IntrusiveQueueHeaderTest::base_hook_item< ci::msqueue::node<cds::gc::DHP > > base_item_type;
+ typedef IntrusiveQueueHeaderTest::member_hook_item< ci::msqueue::node<cds::gc::DHP > > member_item_type;
+
+ // DHP base hook
+ typedef ci::MSQueue< cds::gc::DHP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
+ > MSQueue_DHP_base;
+
+ // DHP member hook
+ typedef ci::MSQueue< cds::gc::DHP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::DHP>
+ >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
+ > MSQueue_DHP_member;
+
+ /// DHP base hook + item counter
+ typedef ci::MSQueue< cds::gc::DHP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> >
+ >
+ , co::item_counter< cds::atomicity::item_counter >
+ , co::memory_model< co::v::relaxed_ordering >
+ >::type
+ > MSQueue_DHP_base_ic;
+
+ // DHP member hook + item counter
+ typedef ci::MSQueue< cds::gc::DHP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::DHP>
+ >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , co::item_counter< cds::atomicity::item_counter >
+ >::type
+ > MSQueue_DHP_member_ic;
+
+ // DHP base hook + stat
+ typedef ci::MSQueue< cds::gc::DHP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , co::stat< ci::msqueue::stat<> >
+ >::type
+ > MSQueue_DHP_base_stat;
+
+ // DHP member hook + stat
+ typedef ci::MSQueue< cds::gc::DHP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::DHP>
+ >
+ >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , co::stat< ci::msqueue::stat<> >
+ >::type
+ > MSQueue_DHP_member_stat;
+
+ // DHP base hook + alignment
+ typedef ci::MSQueue< cds::gc::DHP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ , ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> >
+ >
+ , co::alignment< 32 >
+ >::type
+ > MSQueue_DHP_base_align;
+
+ // DHP member hook + alignment
+ typedef ci::MSQueue< cds::gc::DHP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::DHP>
+ >
+ >
+ , co::alignment< 32 >
+ , ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
+ > MSQueue_DHP_member_align;
+
+ // DHP base hook + no alignment
+ struct traits_MSQueue_DHP_base_noalign : public ci::msqueue::traits {
+ typedef ci::msqueue::base_hook< ci::opt::gc<cds::gc::DHP> > hook;
+ typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
+ enum { alignment = co::no_special_alignment };
+ };
+ typedef ci::MSQueue< cds::gc::DHP, base_item_type, traits_MSQueue_DHP_base_noalign > MSQueue_DHP_base_noalign;
+
+ // DHP member hook + no alignment
+ struct traits_MSQueue_DHP_member_noalign : public ci::msqueue::traits {
+ typedef ci::msqueue::member_hook <
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc < cds::gc::DHP >
+ > hook;
+ typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
+ enum { alignment = co::no_special_alignment };
+ };
+ typedef ci::MSQueue< cds::gc::DHP, member_item_type, traits_MSQueue_DHP_member_noalign > MSQueue_DHP_member_noalign;
+
+
+ // DHP base hook + cache alignment
+ struct traits_MSQueue_DHP_base_cachealign : public traits_MSQueue_DHP_base_noalign
+ {
+ enum { alignment = co::cache_line_alignment };
+ };
+ typedef ci::MSQueue< cds::gc::DHP, base_item_type, traits_MSQueue_DHP_base_cachealign > MSQueue_DHP_base_cachealign;
+
+ // DHP member hook + cache alignment
+ struct traits_MSQueue_DHP_member_cachealign : public traits_MSQueue_DHP_member_noalign
+ {
+ enum { alignment = co::cache_line_alignment };
+ };
+ typedef ci::MSQueue< cds::gc::DHP, member_item_type, traits_MSQueue_DHP_member_cachealign > MSQueue_DHP_member_cachealign;
+ } // namespace
+
+ TEST(MSQueue_DHP_base)
+ TEST(MSQueue_DHP_member)
+ TEST(MSQueue_DHP_base_ic)
+ TEST(MSQueue_DHP_member_ic)
+ TEST(MSQueue_DHP_base_stat)
+ TEST(MSQueue_DHP_member_stat)
+ TEST(MSQueue_DHP_base_align)
+ TEST(MSQueue_DHP_member_align)
+ TEST(MSQueue_DHP_base_noalign)
+ TEST(MSQueue_DHP_member_noalign)
+ TEST(MSQueue_DHP_base_cachealign)
+ TEST(MSQueue_DHP_member_cachealign)
+
+} // namespace queue
//$$CDS-header$$
#include "hdr_intrusive_msqueue.h"
-#include "hdr_intrusive_singlelink_node.h"
#include <cds/intrusive/msqueue.h>
#include <cds/gc/hp.h>
#define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
namespace {
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ typedef IntrusiveQueueHeaderTest::base_hook_item< ci::msqueue::node<cds::gc::HP > > base_item_type;
+ typedef IntrusiveQueueHeaderTest::member_hook_item< ci::msqueue::node<cds::gc::HP > > member_item_type;
+
+ typedef ci::MSQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
> MSQueue_HP_default;
/// HP + item counter
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::item_counter< cds::atomicity::item_counter >
- ,co::memory_model< co::v::sequential_consistent >
+ typedef ci::MSQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::item_counter< cds::atomicity::item_counter >
+ ,co::memory_model< co::v::sequential_consistent >
+ >::type
> MSQueue_HP_default_ic;
/// HP + stat
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
+ typedef ci::MSQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::stat< ci::msqueue::stat<> >
+ >::type
> MSQueue_HP_default_stat;
// HP base hook
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ typedef ci::MSQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
+ >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
> MSQueue_HP_base;
// HP member hook
- typedef ci::MSQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
+ typedef ci::MSQueue< cds::gc::HP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::HP>
+ >
>
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
> MSQueue_HP_member;
/// HP base hook + item counter
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,co::item_counter< cds::atomicity::item_counter >
- ,co::memory_model< co::v::relaxed_ordering >
+ typedef ci::MSQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
+ >
+ ,co::item_counter< cds::atomicity::item_counter >
+ ,co::memory_model< co::v::relaxed_ordering >
+ >::type
> MSQueue_HP_base_ic;
// HP member hook + item counter
- typedef ci::MSQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
+ typedef ci::MSQueue< cds::gc::HP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::HP>
+ >
>
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::item_counter< cds::atomicity::item_counter >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::item_counter< cds::atomicity::item_counter >
+ >::type
> MSQueue_HP_member_ic;
// HP base hook + stat
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
+ typedef ci::MSQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
+ >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::stat< ci::msqueue::stat<> >
+ >::type
> MSQueue_HP_base_stat;
// HP member hook + stat
- typedef ci::MSQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
+ typedef ci::MSQueue< cds::gc::HP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::HP>
+ >
>
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::stat< ci::msqueue::stat<> >
+ >::type
> MSQueue_HP_member_stat;
// HP base hook + alignment
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,co::alignment< 32 >
+ typedef ci::MSQueue< cds::gc::HP, base_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,ci::opt::hook<
+ ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> >
+ >
+ ,co::alignment< 32 >
+ >::type
> MSQueue_HP_base_align;
// HP member hook + alignment
- typedef ci::MSQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
+ typedef ci::MSQueue< cds::gc::HP, member_item_type,
+ typename ci::msqueue::make_traits<
+ ci::opt::hook<
+ ci::msqueue::member_hook<
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc<cds::gc::HP>
+ >
>
- >
- ,co::alignment< 32 >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ ,co::alignment< 32 >
+ ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
+ >::type
> MSQueue_HP_member_align;
// HP base hook + no alignment
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::alignment< co::no_special_alignment >
- > MSQueue_HP_base_noalign;
+ struct traits_MSQueue_HP_base_noalign : public ci::msqueue::traits {
+ typedef ci::msqueue::base_hook< ci::opt::gc<cds::gc::HP> > hook;
+ typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
+ enum { alignment = co::no_special_alignment };
+ };
+ typedef ci::MSQueue< cds::gc::HP, base_item_type, traits_MSQueue_HP_base_noalign > MSQueue_HP_base_noalign;
// HP member hook + no alignment
- typedef ci::MSQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
- >
- >
- ,co::alignment< co::no_special_alignment >
- > MSQueue_HP_member_noalign;
+ struct traits_MSQueue_HP_member_noalign : public ci::msqueue::traits {
+ typedef ci::msqueue::member_hook <
+ offsetof( member_item_type, hMember ),
+ ci::opt::gc < cds::gc::HP >
+ > hook;
+ typedef IntrusiveQueueHeaderTest::faked_disposer disposer;
+ enum { alignment = co::no_special_alignment };
+ };
+ typedef ci::MSQueue< cds::gc::HP, member_item_type, traits_MSQueue_HP_member_noalign > MSQueue_HP_member_noalign;
// HP base hook + cache alignment
- typedef ci::MSQueue< cds::gc::HP,
- base_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HP> >
- >
- ,co::alignment< co::cache_line_alignment >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MSQueue_HP_base_cachealign;
+ struct traits_MSQueue_HP_base_cachealign : public traits_MSQueue_HP_base_noalign
+ {
+ enum { alignment = co::cache_line_alignment };
+ };
+ typedef ci::MSQueue< cds::gc::HP, base_item_type, traits_MSQueue_HP_base_cachealign > MSQueue_HP_base_cachealign;
// HP member hook + cache alignment
- typedef ci::MSQueue< cds::gc::HP,
- member_hook_item<cds::gc::HP>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::HP>, hMember),
- ci::opt::gc<cds::gc::HP>
- >
- >
- ,co::alignment< co::cache_line_alignment >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MSQueue_HP_member_cachealign;
+ struct traits_MSQueue_HP_member_cachealign : public traits_MSQueue_HP_member_noalign
+ {
+ enum { alignment = co::cache_line_alignment };
+ };
+ typedef ci::MSQueue< cds::gc::HP, member_item_type, traits_MSQueue_HP_member_cachealign > MSQueue_HP_member_cachealign;
}
+++ /dev/null
-//$$CDS-header$$
-
-#include "hdr_intrusive_msqueue.h"
-#include "hdr_intrusive_singlelink_node.h"
-
-#include <cds/intrusive/msqueue.h>
-#include <cds/gc/hrc.h>
-
-namespace queue {
-
-#define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
-
- namespace {
-
- // HRC base hook
- typedef ci::MSQueue< cds::gc::HRC,
- base_hook_item<cds::gc::HRC>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HRC> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MSQueue_HRC_base;
-
- // HRC base hook + item counter
- typedef ci::MSQueue< cds::gc::HRC,
- base_hook_item<cds::gc::HRC>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HRC> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::item_counter< cds::atomicity::item_counter >
- > MSQueue_HRC_base_ic;
-
- // HRC base hook + stat
- typedef ci::MSQueue< cds::gc::HRC,
- base_hook_item<cds::gc::HRC>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HRC> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
- > MSQueue_HRC_base_stat;
-
- // HRC base hook + alignment
- typedef ci::MSQueue< cds::gc::HRC,
- base_hook_item<cds::gc::HRC>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::HRC> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::alignment< 128 >
- > MSQueue_HRC_base_align;
- }
-
- TEST(MSQueue_HRC_base)
- TEST(MSQueue_HRC_base_ic)
- TEST(MSQueue_HRC_base_stat)
- TEST(MSQueue_HRC_base_align)
-
-} // namespace queue
+++ /dev/null
-//$$CDS-header$$
-
-#include "hdr_intrusive_msqueue.h"
-#include "hdr_intrusive_singlelink_node.h"
-
-#include <cds/intrusive/msqueue.h>
-#include <cds/gc/ptb.h>
-
-namespace queue {
-
-#define TEST(X) void IntrusiveQueueHeaderTest::test_##X() { test<X>(); }
-
- namespace {
-
- // PTB base hook
- typedef ci::MSQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MSQueue_PTB_base;
-
- // PTB member hook
- typedef ci::MSQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MSQueue_PTB_member;
-
- /// PTB base hook + item counter
- typedef ci::MSQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,co::item_counter< cds::atomicity::item_counter >
- > MSQueue_PTB_base_ic;
-
- // PTB member hook + item counter
- typedef ci::MSQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::item_counter< cds::atomicity::item_counter >
- > MSQueue_PTB_member_ic;
-
- // PTB base hook + stat
- typedef ci::MSQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
- > MSQueue_PTB_base_stat;
-
- // PTB member hook + stat
- typedef ci::MSQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::stat< ci::queue_stat<> >
- > MSQueue_PTB_member_stat;
-
- // PTB base hook + alignment
- typedef ci::MSQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,co::alignment< 32 >
- > MSQueue_PTB_base_align;
-
- // PTB member hook + alignment
- typedef ci::MSQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,co::alignment< 32 >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MSQueue_PTB_member_align;
-
- // PTB base hook + no alignment
- typedef ci::MSQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,co::alignment< co::no_special_alignment >
- > MSQueue_PTB_base_noalign;
-
- // PTB member hook + no alignment
- typedef ci::MSQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,co::alignment< co::no_special_alignment >
- > MSQueue_PTB_member_noalign;
-
-
- // PTB base hook + cache alignment
- typedef ci::MSQueue< cds::gc::PTB,
- base_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::base_hook< ci::opt::gc<cds::gc::PTB> >
- >
- ,co::alignment< co::cache_line_alignment >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MSQueue_PTB_base_cachealign;
-
- // PTB member hook + cache alignment
- typedef ci::MSQueue< cds::gc::PTB,
- member_hook_item<cds::gc::PTB>
- ,ci::opt::hook<
- ci::single_link::member_hook<
- offsetof(member_hook_item<cds::gc::PTB>, hMember),
- ci::opt::gc<cds::gc::PTB>
- >
- >
- ,co::alignment< co::cache_line_alignment >
- ,ci::opt::disposer< IntrusiveQueueHeaderTest::faked_disposer >
- > MSQueue_PTB_member_cachealign;
-
- } // namespace
-
- TEST(MSQueue_PTB_base)
- TEST(MSQueue_PTB_member)
- TEST(MSQueue_PTB_base_ic)
- TEST(MSQueue_PTB_member_ic)
- TEST(MSQueue_PTB_base_stat)
- TEST(MSQueue_PTB_member_stat)
- TEST(MSQueue_PTB_base_align)
- TEST(MSQueue_PTB_member_align)
- TEST(MSQueue_PTB_base_noalign)
- TEST(MSQueue_PTB_member_noalign)
- TEST(MSQueue_PTB_base_cachealign)
- TEST(MSQueue_PTB_member_cachealign)
-
-} // namespace queue
// MSQueue
#define CDSUNIT_DECLARE_MSQueue \
- TEST_CASE(MSQueue_HP, cds::intrusive::single_link::node< cds::gc::HP > ) \
- TEST_CASE(MSQueue_HP_ic, cds::intrusive::single_link::node< cds::gc::HP > ) \
- TEST_CASE(MSQueue_HP_stat, cds::intrusive::single_link::node< cds::gc::HP > ) \
- TEST_CASE(MSQueue_HP_seqcst, cds::intrusive::single_link::node< cds::gc::HP > ) \
- TEST_CASE(MSQueue_HRC, cds::intrusive::single_link::node< cds::gc::HRC > ) \
- TEST_CASE(MSQueue_HRC_ic, cds::intrusive::single_link::node< cds::gc::HRC > ) \
- TEST_CASE(MSQueue_HRC_stat, cds::intrusive::single_link::node< cds::gc::HRC > ) \
- TEST_CASE(MSQueue_HRC_seqcst, cds::intrusive::single_link::node< cds::gc::HRC > ) \
- TEST_CASE(MSQueue_PTB, cds::intrusive::single_link::node< cds::gc::PTB > ) \
- TEST_CASE(MSQueue_PTB_ic, cds::intrusive::single_link::node< cds::gc::PTB > ) \
- TEST_CASE(MSQueue_PTB_stat, cds::intrusive::single_link::node< cds::gc::PTB > ) \
- TEST_CASE(MSQueue_PTB_seqcst, cds::intrusive::single_link::node< cds::gc::PTB > )
+ TEST_CASE(MSQueue_HP, cds::intrusive::msqueue::node< cds::gc::HP > ) \
+ TEST_CASE(MSQueue_HP_ic, cds::intrusive::msqueue::node< cds::gc::HP > ) \
+ TEST_CASE(MSQueue_HP_stat, cds::intrusive::msqueue::node< cds::gc::HP > ) \
+ TEST_CASE(MSQueue_HP_seqcst, cds::intrusive::msqueue::node< cds::gc::HP > ) \
+ TEST_CASE(MSQueue_DHP, cds::intrusive::msqueue::node< cds::gc::DHP > ) \
+ TEST_CASE(MSQueue_DHP_ic, cds::intrusive::msqueue::node< cds::gc::DHP > ) \
+ TEST_CASE(MSQueue_DHP_stat, cds::intrusive::msqueue::node< cds::gc::DHP > ) \
+ TEST_CASE(MSQueue_DHP_seqcst, cds::intrusive::msqueue::node< cds::gc::DHP > )
#define CDSUNIT_TEST_MSQueue \
CPPUNIT_TEST(MSQueue_HP) \
CPPUNIT_TEST(MSQueue_HP_ic) \
CPPUNIT_TEST(MSQueue_HP_stat) \
CPPUNIT_TEST(MSQueue_HP_seqcst) \
- /*CPPUNIT_TEST(MSQueue_HRC)*/ \
- /*CPPUNIT_TEST(MSQueue_HRC_ic)*/ \
- /*CPPUNIT_TEST(MSQueue_HRC_stat)*/ \
- /*CPPUNIT_TEST(MSQueue_HRC_seqcst)*/ \
- CPPUNIT_TEST(MSQueue_PTB) \
- CPPUNIT_TEST(MSQueue_PTB_ic) \
- CPPUNIT_TEST(MSQueue_PTB_stat) \
- CPPUNIT_TEST(MSQueue_PTB_seqcst)
+ CPPUNIT_TEST(MSQueue_DHP) \
+ CPPUNIT_TEST(MSQueue_DHP_ic) \
+ CPPUNIT_TEST(MSQueue_DHP_stat) \
+ CPPUNIT_TEST(MSQueue_DHP_seqcst)
// MoirQueue
#define CDSUNIT_DECLARE_MoirQueue \
- TEST_CASE(MoirQueue_HP, cds::intrusive::single_link::node< cds::gc::HP > ) \
- TEST_CASE(MoirQueue_HP_ic, cds::intrusive::single_link::node< cds::gc::HP > ) \
- TEST_CASE(MoirQueue_HP_stat, cds::intrusive::single_link::node< cds::gc::HP > ) \
- TEST_CASE(MoirQueue_HP_seqcst, cds::intrusive::single_link::node< cds::gc::HP > ) \
- TEST_CASE(MoirQueue_HRC, cds::intrusive::single_link::node< cds::gc::HRC > ) \
- TEST_CASE(MoirQueue_HRC_ic, cds::intrusive::single_link::node< cds::gc::HRC > ) \
- TEST_CASE(MoirQueue_HRC_stat, cds::intrusive::single_link::node< cds::gc::HRC > ) \
- TEST_CASE(MoirQueue_HRC_seqcst, cds::intrusive::single_link::node< cds::gc::HRC > ) \
- TEST_CASE(MoirQueue_PTB, cds::intrusive::single_link::node< cds::gc::PTB > ) \
- TEST_CASE(MoirQueue_PTB_ic, cds::intrusive::single_link::node< cds::gc::PTB > ) \
- TEST_CASE(MoirQueue_PTB_stat, cds::intrusive::single_link::node< cds::gc::PTB > ) \
- TEST_CASE(MoirQueue_PTB_seqcst, cds::intrusive::single_link::node< cds::gc::PTB > )
+ TEST_CASE(MoirQueue_HP, cds::intrusive::msqueue::node< cds::gc::HP > ) \
+ TEST_CASE(MoirQueue_HP_ic, cds::intrusive::msqueue::node< cds::gc::HP > ) \
+ TEST_CASE(MoirQueue_HP_stat, cds::intrusive::msqueue::node< cds::gc::HP > ) \
+ TEST_CASE(MoirQueue_HP_seqcst, cds::intrusive::msqueue::node< cds::gc::HP > ) \
+ TEST_CASE(MoirQueue_DHP, cds::intrusive::msqueue::node< cds::gc::DHP > ) \
+ TEST_CASE(MoirQueue_DHP_ic, cds::intrusive::msqueue::node< cds::gc::DHP > ) \
+ TEST_CASE(MoirQueue_DHP_stat, cds::intrusive::msqueue::node< cds::gc::DHP > ) \
+ TEST_CASE(MoirQueue_DHP_seqcst, cds::intrusive::msqueue::node< cds::gc::DHP > )
#define CDSUNIT_TEST_MoirQueue \
CPPUNIT_TEST(MoirQueue_HP) \
CPPUNIT_TEST(MoirQueue_HP_ic) \
CPPUNIT_TEST(MoirQueue_HP_stat) \
CPPUNIT_TEST(MoirQueue_HP_seqcst) \
- /*CPPUNIT_TEST(MoirQueue_HRC)*/ \
- /*CPPUNIT_TEST(MoirQueue_HRC_ic)*/ \
- /*CPPUNIT_TEST(MoirQueue_HRC_stat)*/ \
- /*CPPUNIT_TEST(MoirQueue_HRC_seqcst)*/ \
- CPPUNIT_TEST(MoirQueue_PTB) \
- CPPUNIT_TEST(MoirQueue_PTB_ic) \
- CPPUNIT_TEST(MoirQueue_PTB_stat) \
- CPPUNIT_TEST(MoirQueue_PTB_seqcst)
+ CPPUNIT_TEST(MoirQueue_DHP) \
+ CPPUNIT_TEST(MoirQueue_DHP_ic) \
+ CPPUNIT_TEST(MoirQueue_DHP_stat) \
+ CPPUNIT_TEST(MoirQueue_DHP_seqcst)
// OptimisticQueue
#include <cds/gc/hp.h>
#include <cds/gc/hrc.h>
-#include <cds/gc/ptb.h>
+#include <cds/gc/dhp.h>
#include <boost/intrusive/slist.hpp>
template <typename T>
struct Types {
- // MSQueue
- typedef cds::intrusive::MSQueue< cds::gc::HP, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HP > > >
- > MSQueue_HP;
-
- typedef cds::intrusive::MSQueue< cds::gc::HP, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HP > > >
- ,cds::opt::memory_model< cds::opt::v::sequential_consistent >
- > MSQueue_HP_seqcst;
-
- typedef cds::intrusive::MSQueue< cds::gc::HRC, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HRC > > >
- > MSQueue_HRC;
+ // MSQueue, MoirQueue
+ struct traits_MSQueue_HP : public cds::intrusive::msqueue::traits
+ {
+ typedef cds::intrusive::msqueue::base_hook< cds::opt::gc< cds::gc::HP > > hook;
+ };
+ typedef cds::intrusive::MSQueue< cds::gc::HP, T, traits_MSQueue_HP > MSQueue_HP;
+ typedef cds::intrusive::MoirQueue< cds::gc::HP, T, traits_MSQueue_HP > MoirQueue_HP;
- typedef cds::intrusive::MSQueue< cds::gc::HRC, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HRC > > >
- ,cds::opt::memory_model< cds::opt::v::sequential_consistent >
- > MSQueue_HRC_seqcst;
+ struct traits_MSQueue_HP_seqcst : public cds::intrusive::msqueue::traits
+ {
+ typedef cds::intrusive::msqueue::base_hook< cds::opt::gc< cds::gc::HP > > hook;
+ typedef cds::opt::v::sequential_consistent memory_model;
+ };
+ typedef cds::intrusive::MSQueue< cds::gc::HP, T, traits_MSQueue_HP_seqcst > MSQueue_HP_seqcst;
+ typedef cds::intrusive::MoirQueue< cds::gc::HP, T, traits_MSQueue_HP_seqcst > MoirQueue_HP_seqcst;
- typedef cds::intrusive::MSQueue< cds::gc::PTB, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::PTB > > >
- > MSQueue_PTB;
+ struct traits_MSQueue_DHP : public cds::intrusive::msqueue::traits
+ {
+ typedef cds::intrusive::msqueue::base_hook< cds::opt::gc< cds::gc::DHP > > hook;
+ };
+ typedef cds::intrusive::MSQueue< cds::gc::DHP, T, traits_MSQueue_DHP > MSQueue_DHP;
+ typedef cds::intrusive::MoirQueue< cds::gc::DHP, T, traits_MSQueue_DHP > MoirQueue_DHP;
- typedef cds::intrusive::MSQueue< cds::gc::PTB, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::PTB > > >
- ,cds::opt::memory_model< cds::opt::v::sequential_consistent >
- > MSQueue_PTB_seqcst;
+ struct traits_MSQueue_DHP_seqcst : public cds::intrusive::msqueue::traits
+ {
+ typedef cds::intrusive::msqueue::base_hook< cds::opt::gc< cds::gc::DHP > > hook;
+ typedef cds::opt::v::sequential_consistent memory_model;
+ };
+ typedef cds::intrusive::MSQueue< cds::gc::DHP, T, traits_MSQueue_DHP_seqcst > MSQueue_DHP_seqcst;
+ typedef cds::intrusive::MoirQueue< cds::gc::DHP, T, traits_MSQueue_DHP_seqcst > MoirQueue_DHP_seqcst;
// MSQueue + item counter
- typedef cds::intrusive::MSQueue< cds::gc::HP, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HP > > >
- ,cds::opt::item_counter< cds::atomicity::item_counter >
- > MSQueue_HP_ic;
-
- typedef cds::intrusive::MSQueue< cds::gc::HRC, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HRC > > >
- ,cds::opt::item_counter< cds::atomicity::item_counter >
- > MSQueue_HRC_ic;
+ struct traits_MSQueue_HP_ic : public cds::intrusive::msqueue::traits
+ {
+ typedef cds::intrusive::msqueue::base_hook< cds::opt::gc< cds::gc::HP > > hook;
+ typedef cds::atomicity::item_counter item_counter;
+ };
+ typedef cds::intrusive::MSQueue< cds::gc::HP, T, traits_MSQueue_HP_ic > MSQueue_HP_ic;
+ typedef cds::intrusive::MoirQueue< cds::gc::HP, T, traits_MSQueue_HP_ic > MoirQueue_HP_ic;
- typedef cds::intrusive::MSQueue< cds::gc::PTB, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::PTB > > >
- ,cds::opt::item_counter< cds::atomicity::item_counter >
- > MSQueue_PTB_ic;
+ struct traits_MSQueue_DHP_ic : public cds::intrusive::msqueue::traits
+ {
+ typedef cds::intrusive::msqueue::base_hook< cds::opt::gc< cds::gc::DHP > > hook;
+ typedef cds::atomicity::item_counter item_counter;
+ };
+ typedef cds::intrusive::MSQueue< cds::gc::DHP, T, traits_MSQueue_DHP_ic > MSQueue_DHP_ic;
+ typedef cds::intrusive::MoirQueue< cds::gc::DHP, T, traits_MSQueue_DHP_ic > MoirQueue_DHP_ic;
// MSQueue + stat
- typedef cds::intrusive::MSQueue< cds::gc::HP, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HP > > >
- ,cds::opt::stat< cds::intrusive::queue_stat<> >
- > MSQueue_HP_stat;
-
- typedef cds::intrusive::MSQueue< cds::gc::HRC, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HRC > > >
- ,cds::opt::stat< cds::intrusive::queue_stat<> >
- > MSQueue_HRC_stat;
-
- typedef cds::intrusive::MSQueue< cds::gc::PTB, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::PTB > > >
- ,cds::opt::stat< cds::intrusive::queue_stat<> >
- > MSQueue_PTB_stat;
-
-
- // MoirQueue
- typedef cds::intrusive::MoirQueue< cds::gc::HP, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HP > > >
- > MoirQueue_HP;
-
- typedef cds::intrusive::MoirQueue< cds::gc::HP, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HP > > >
- ,cds::opt::memory_model< cds::opt::v::sequential_consistent >
- > MoirQueue_HP_seqcst;
-
- typedef cds::intrusive::MoirQueue< cds::gc::HRC, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HRC > > >
- > MoirQueue_HRC;
-
- typedef cds::intrusive::MoirQueue< cds::gc::HRC, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HRC > > >
- ,cds::opt::memory_model< cds::opt::v::sequential_consistent >
- > MoirQueue_HRC_seqcst;
-
- typedef cds::intrusive::MoirQueue< cds::gc::PTB, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::PTB > > >
- > MoirQueue_PTB;
-
- typedef cds::intrusive::MoirQueue< cds::gc::PTB, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::PTB > > >
- ,cds::opt::memory_model< cds::opt::v::sequential_consistent >
- > MoirQueue_PTB_seqcst;
-
- // MoirQueue + item counter
- typedef cds::intrusive::MoirQueue< cds::gc::HP, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HP > > >
- ,cds::opt::item_counter< cds::atomicity::item_counter >
- > MoirQueue_HP_ic;
-
- typedef cds::intrusive::MoirQueue< cds::gc::HRC, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HRC > > >
- ,cds::opt::item_counter< cds::atomicity::item_counter >
- > MoirQueue_HRC_ic;
-
- typedef cds::intrusive::MoirQueue< cds::gc::PTB, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::PTB > > >
- ,cds::opt::item_counter< cds::atomicity::item_counter >
- > MoirQueue_PTB_ic;
-
- // MoirQueue + stat
- typedef cds::intrusive::MoirQueue< cds::gc::HP, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HP > > >
- ,cds::opt::stat< cds::intrusive::queue_stat<> >
- > MoirQueue_HP_stat;
+ struct traits_MSQueue_HP_stat : public cds::intrusive::msqueue::traits
+ {
+ typedef cds::intrusive::msqueue::base_hook< cds::opt::gc< cds::gc::HP > > hook;
+ typedef cds::intrusive::msqueue::stat<> stat;
+ };
+ typedef cds::intrusive::MSQueue< cds::gc::HP, T, traits_MSQueue_HP_stat > MSQueue_HP_stat;
+ typedef cds::intrusive::MoirQueue< cds::gc::HP, T, traits_MSQueue_HP_stat > MoirQueue_HP_stat;
- typedef cds::intrusive::MoirQueue< cds::gc::HRC, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::HRC > > >
- ,cds::opt::stat< cds::intrusive::queue_stat<> >
- > MoirQueue_HRC_stat;
+ struct traits_MSQueue_DHP_stat : public cds::intrusive::msqueue::traits
+ {
+ typedef cds::intrusive::msqueue::base_hook< cds::opt::gc< cds::gc::DHP > > hook;
+ typedef cds::intrusive::msqueue::stat<> stat;
+ };
+ typedef cds::intrusive::MSQueue< cds::gc::DHP, T, traits_MSQueue_DHP_stat > MSQueue_DHP_stat;
+ typedef cds::intrusive::MoirQueue< cds::gc::DHP, T, traits_MSQueue_DHP_stat > MoirQueue_DHP_stat;
- typedef cds::intrusive::MoirQueue< cds::gc::PTB, T
- ,cds::intrusive::opt::hook< cds::intrusive::single_link::base_hook< cds::opt::gc< cds::gc::PTB > > >
- ,cds::opt::stat< cds::intrusive::queue_stat<> >
- > MoirQueue_PTB_stat;
// OptimisticQueue
typedef cds::intrusive::OptimisticQueue< cds::gc::HP, T
// cds::intrusive::queue_stat
template <typename Counter>
- static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::queue_stat<Counter> const& s )
+ static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::msqueue::stat<Counter> const& s )
{
return o
<< "\tStatistics:\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 Bad tail: " << s.m_BadTail.get() << "\n";
}
static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::queue_dummy_stat const& s )