From 18e59aed6abaa4e8d9f1c88f3545c6f963a30c51 Mon Sep 17 00:00:00 2001 From: khizmax Date: Mon, 6 Oct 2014 13:45:36 +0400 Subject: [PATCH] MSQueue/MoirQueue refactoring (phase 2, not completed) --- cds/container/moir_queue.h | 290 +++++------- cds/container/msqueue.h | 78 ++-- cds/intrusive/msqueue.h | 39 +- change.log | 2 + projects/Win/vc12/hdr-test-queue.vcxproj | 15 +- .../Win/vc12/hdr-test-queue.vcxproj.filters | 39 +- projects/source.test-hdr.mk | 12 +- tests/test-hdr/queue/hdr_basketqueue_hrc.cpp | 2 +- tests/test-hdr/queue/hdr_basketqueue_hzp.cpp | 2 +- tests/test-hdr/queue/hdr_basketqueue_ptb.cpp | 2 +- tests/test-hdr/queue/hdr_fcqueue.cpp | 2 +- .../queue/hdr_intrusive_msqueue_hp.cpp | 1 - .../hdr_intrusive_segmented_queue_hp.cpp | 2 - tests/test-hdr/queue/hdr_moirqueue_dhp.cpp | 120 +++++ tests/test-hdr/queue/hdr_moirqueue_hp.cpp | 121 +++++ tests/test-hdr/queue/hdr_moirqueue_hrc.cpp | 107 ----- tests/test-hdr/queue/hdr_moirqueue_hzp.cpp | 107 ----- tests/test-hdr/queue/hdr_moirqueue_ptb.cpp | 107 ----- tests/test-hdr/queue/hdr_msqueue_dhp.cpp | 121 +++++ tests/test-hdr/queue/hdr_msqueue_hp.cpp | 121 +++++ tests/test-hdr/queue/hdr_msqueue_hrc.cpp | 107 ----- tests/test-hdr/queue/hdr_msqueue_hzp.cpp | 107 ----- tests/test-hdr/queue/hdr_msqueue_ptb.cpp | 107 ----- tests/test-hdr/queue/hdr_optimistic_hzp.cpp | 2 +- tests/test-hdr/queue/hdr_optimistic_ptb.cpp | 2 +- .../{queue_test_header.h => hdr_queue.h} | 124 ++---- tests/test-hdr/queue/hdr_queue_new.h | 417 ++++++++++++++++++ tests/test-hdr/queue/hdr_queue_register.cpp | 13 + tests/test-hdr/queue/hdr_rwqueue.cpp | 2 +- .../test-hdr/queue/hdr_segmented_queue_hp.cpp | 2 - .../test-hdr/queue/hdr_vyukov_mpmc_cyclic.cpp | 2 +- tests/test-hdr/queue/queue_test_header.cpp | 4 - tests/unit/queue/intrusive_queue_type.h | 2 +- 33 files changed, 1169 insertions(+), 1012 deletions(-) create mode 100644 tests/test-hdr/queue/hdr_moirqueue_dhp.cpp create mode 100644 tests/test-hdr/queue/hdr_moirqueue_hp.cpp delete mode 100644 tests/test-hdr/queue/hdr_moirqueue_hrc.cpp delete mode 100644 tests/test-hdr/queue/hdr_moirqueue_hzp.cpp delete mode 100644 tests/test-hdr/queue/hdr_moirqueue_ptb.cpp create mode 100644 tests/test-hdr/queue/hdr_msqueue_dhp.cpp create mode 100644 tests/test-hdr/queue/hdr_msqueue_hp.cpp delete mode 100644 tests/test-hdr/queue/hdr_msqueue_hrc.cpp delete mode 100644 tests/test-hdr/queue/hdr_msqueue_hzp.cpp delete mode 100644 tests/test-hdr/queue/hdr_msqueue_ptb.cpp rename tests/test-hdr/queue/{queue_test_header.h => hdr_queue.h} (76%) create mode 100644 tests/test-hdr/queue/hdr_queue_new.h create mode 100644 tests/test-hdr/queue/hdr_queue_register.cpp delete mode 100644 tests/test-hdr/queue/queue_test_header.cpp diff --git a/cds/container/moir_queue.h b/cds/container/moir_queue.h index 38ac55d2..0628cde7 100644 --- a/cds/container/moir_queue.h +++ b/cds/container/moir_queue.h @@ -4,123 +4,83 @@ #define __CDS_CONTAINER_MOIR_QUEUE_H #include -#include // ref +#include #include -#include -#include -#include namespace cds { namespace container { //@cond namespace details { - template - struct make_moir_queue + template + struct make_moir_queue: public cds::container::details::make_msqueue< GC, T, Traits > { - typedef GC gc; - typedef T value_type; - - 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 > - { - value_type m_value; - - node_type( const value_type& val ) - : m_value( val ) - {} - - template - node_type( Args&&... args ) - : m_value( std::forward(args)...) - {} - }; - - typedef typename options::allocator::template rebind::other allocator_type; - typedef cds::details::Allocator< node_type, allocator_type > cxx_allocator; - - struct node_deallocator - { - void operator ()( node_type * pNode ) - { - cxx_allocator().Delete( pNode ); - } - }; - - typedef intrusive::MoirQueue< - gc - ,node_type - ,intrusive::opt::hook< - intrusive::single_link::base_hook< opt::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; + typedef cds::container::details::make_msqueue< GC, T, Traits > base_class; + typedef cds::intrusive::MoirQueue< GC, base_class::node_type, base_class::intrusive_traits > type; }; } //@endcond /// A variation of Michael & Scott's lock-free queue /** @ingroup cds_nonintrusive_queue - It is non-intrusive version of intrusive::MoirQueue. - - \p T is a type stored in the queue. It should be default-constructible, copy-constructible, assignable type. + It is non-intrusive version of \p cds::intrusive::MoirQueue. - \p Options description see MSQueue + Template arguments: + - \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::MoirQueue< cds::gc::HP, Foo, myTraits > myQueue; + + // Equivalent make_traits example: + typedef cds::container::MoirQueue< 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 + template class MoirQueue: #ifdef CDS_DOXYGEN_INVOKED - intrusive::MoirQueue< GC, intrusive::single_link::node< T >, Options... > + intrusive::MoirQueue< GC, intrusive::msqueue::node< T >, Traits > #else - details::make_moir_queue< GC, T, Options... >::type + details::make_moir_queue< GC, T, Traits >::type #endif { //@cond - typedef details::make_moir_queue< GC, T, Options... > options; - typedef typename options::type base_class; + typedef details::make_moir_queue< GC, T, Traits > maker; + typedef typename maker::type base_class; //@endcond public: /// Rebind template arguments - template + template struct rebind { - typedef MoirQueue< GC2, T2, Options2...> other ; ///< Rebinding result + typedef MoirQueue< GC2, T2, Traits2 > other ; ///< Rebinding result }; public: typedef T value_type ; ///< Value type stored in the stack - - 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 options::options::item_counter item_counter ; ///< Item counting policy used - typedef typename options::options::stat stat ; ///< Internal statistics policy used - typedef typename base_class::memory_model memory_model ; ///< Memory ordering. See cds::opt::memory_model option + typedef typename base_class::gc gc; ///< Garbage collector + typedef typename base_class::back_off back_off; ///< Back-off strategy + 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) - //@cond - typedef typename options::cxx_allocator cxx_allocator; - typedef typename options::node_deallocator node_deallocator; // deallocate node - typedef typename base_class::node_traits node_traits; + typedef typename maker::node_type node_type; ///< queue node type (derived from intrusive::msqueue::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 protected: @@ -161,22 +121,10 @@ namespace cds { namespace container { ~MoirQueue() {} - /// Returns queue's item count (see \ref intrusive::MSQueue::size for explanation) - size_t size() const - { - return base_class::size(); - } - - /// Returns refernce to internal statistics - const stat& statistics() const - { - return base_class::statistics(); - } - /// Enqueues \p val value into the queue. /** The function makes queue node in dynamic memory calling copy constructor for \p val - and then it calls intrusive::MSQueue::enqueue. + and then it calls intrusive::MoirQueue::enqueue. Returns \p true if success, \p false otherwise. */ bool enqueue( value_type const& val ) @@ -189,29 +137,22 @@ namespace cds { namespace container { 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 \p T stored in the queue. - The functor's interface is: + \p Func is a functor called to create node. + The functor should initialize creating node + and it \p f takes one argument - a reference to a new node of type \ref value_type: \code - struct myFunctor { - void operator()(T& dest, SOURCE const& data) - { - // // Code to copy \p data to \p dest - dest = data; - } - }; + cds:container::MoirQueue< 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. - - Requirements The functor \p Func should not throw any exception. */ - template - bool enqueue( const Type& data, Func f ) + template + bool enqueue_with( Func f ) { - scoped_node_ptr p( alloc_node()); - f( node_traits::to_value_ptr( *p )->m_value, data ); + scoped_node_ptr p( alloc_node() ); + f( p->m_value ); if ( base_class::enqueue( *p )) { p.release(); return true; @@ -219,38 +160,31 @@ namespace cds { namespace container { return false; } - /// Dequeues a value using copy functor - /** - \p Func is a functor called to copy dequeued value to \p dest of type \p Type - which may be differ from type \p T stored in the queue. - The functor's interface is: - \code - struct myFunctor { - void operator()(Type& dest, T const& data) - { - // // Code to copy \p data to \p dest - dest = data; - } - }; - \endcode - You may use \p boost:ref construction to pass functor \p f by reference. - - Requirements The functor \p Func should not throw any exception. - */ - template - bool dequeue( Type& dest, Func f ) + /// Enqueues data of type \ref value_type constructed with std::forward(args)... + template + bool emplace( Args&&... args ) { - typename base_class::dequeue_result res; - if ( base_class::do_dequeue( res )) { - f( dest, node_traits::to_value_ptr( *res.pNext )->m_value ); - - base_class::dispose_result( res ); - + scoped_node_ptr p( alloc_node_move( std::forward( args )... ) ); + if ( base_class::enqueue( *p ) ) { + p.release(); return true; } return false; } + /// Synonym for \p enqueue() function + bool push( value_type const& val ) + { + return enqueue( val ); + } + + /// Synonym for \p enqueue_with() function + template + bool push_with( Func f ) + { + return enqueue_with( f ); + } + /// Dequeues a value from the queue /** If queue is not empty, the function returns \p true, \p dest contains copy of @@ -259,52 +193,43 @@ namespace cds { namespace container { */ bool dequeue( value_type& dest ) { - typedef cds::details::trivial_assign functor; - return dequeue( dest, functor() ); + return dequeue_with( [&dest]( value_type& src ) { dest = src; } ); } - /// Synonym for \ref enqueue function - bool push( const value_type& val ) - { - return enqueue( val ); - } - - /// Synonym for template version of \ref enqueue function - template - bool push( const Type& data, Func f ) - { - return enqueue( data, f ); - } - - /// Enqueues data of type \ref value_type constructed with std::forward(args)... - template - bool emplace( Args&&... args ) + /// Dequeues a value using a functor + /** + \p Func is a functor called to copy dequeued value. + The functor takes one argument - a reference to removed node: + \code + cds:container::MoirQueue< cds::gc::HP, Foo > myQueue; + Bar bar; + myQueue.dequeue_with( [&bar]( Foo& src ) { bar = std::move( src );}); + \endcode + The functor is called only if the queue is not empty. + */ + template + bool dequeue_with( Func f ) { - scoped_node_ptr p( alloc_node_move( std::forward(args)... )); - if ( base_class::enqueue( *p )) { - p.release(); + typename base_class::dequeue_result res; + if ( base_class::do_dequeue( res )) { + f( node_traits::to_value_ptr( *res.pNext )->m_value ); + base_class::dispose_result( res ); return true; } return false; } - /// Synonym for \ref dequeue function + /// Synonym for \p dequeue() function bool pop( value_type& dest ) { return dequeue( dest ); } - /// Synonym for template version of \ref dequeue function - template - bool pop( Type& dest, Func f ) + /// Synonym for \p dequeue_with() function + template + bool pop_with( Func f ) { - return dequeue( dest, f ); - } - - /// Checks if the queue is empty - bool empty() const - { - return base_class::empty(); + return dequeue_with( f ); } /// Clear the queue @@ -317,6 +242,25 @@ namespace cds { namespace container { { base_class::clear(); } + + /// Checks if the queue is empty + bool empty() const + { + return base_class::empty(); + } + + /// Returns queue's item count (see \ref intrusive::MSQueue::size for explanation) + size_t size() const + { + return base_class::size(); + } + + /// Returns refernce to internal statistics + const stat& statistics() const + { + return base_class::statistics(); + } + }; }} // namespace cds::container diff --git a/cds/container/msqueue.h b/cds/container/msqueue.h index dddf73ed..7fbdd782 100644 --- a/cds/container/msqueue.h +++ b/cds/container/msqueue.h @@ -4,7 +4,6 @@ #define __CDS_CONTAINER_MSQUEUE_H #include -#include // ref #include #include @@ -98,7 +97,7 @@ namespace cds { namespace container { typedef T value_type; typedef Traits traits; - struct node_type: public intrusive::msqueue::node< gc > + struct node_type : public intrusive::msqueue::node< gc > { value_type m_value; @@ -108,7 +107,7 @@ namespace cds { namespace container { template node_type( Args&&... args ) - : m_value( std::forward(args)...) + : m_value( std::forward( args )... ) {} }; @@ -160,7 +159,7 @@ namespace cds { namespace container { > myQueue; \endcode */ - template + template class MSQueue: #ifdef CDS_DOXYGEN_INVOKED intrusive::MSQueue< GC, cds::intrusive::msqueue::node< T >, Traits > @@ -190,12 +189,12 @@ namespace cds { namespace container { typedef typename base_class::memory_model memory_model; ///< Memory ordering. See cds::opt::memory_model option protected: - typedef typename maker::node_type node_type ; ///< queue node type (derived from \p intrusive::msqueue::node) - //@cond + typedef typename maker::node_type node_type; ///< queue node type (derived from \p intrusive::msqueue::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; + typedef typename base_class::node_traits node_traits; //@endcond protected: @@ -236,18 +235,6 @@ namespace cds { namespace container { ~MSQueue() {} - /// Returns queue's item count (see \ref intrusive::MSQueue::size for explanation) - size_t size() const - { - return base_class::size(); - } - - /// Returns reference to internal statistics - const stat& statistics() const - { - return base_class::statistics(); - } - /// Enqueues \p val value into the queue. /** The function makes queue node in dynamic memory calling copy constructor for \p val @@ -298,7 +285,7 @@ namespace cds { namespace container { return false; } - /// Synonym for \ref enqueue function + /// Synonym for \p enqueue() function bool push( value_type const& val ) { return enqueue( val ); @@ -311,6 +298,17 @@ namespace cds { namespace container { return enqueue_with( f ); } + /// Dequeues a value from the queue + /** + If queue is not empty, the function returns \p true, \p dest contains copy of + dequeued value. The assignment operator for type \ref value_type is invoked. + If queue is empty, the function returns \p false, \p dest is unchanged. + */ + bool dequeue( value_type& dest ) + { + return dequeue_with( [&dest]( value_type& src ) { dest = src; } ); + } + /// Dequeues a value using a functor /** \p Func is a functor called to copy dequeued value. @@ -320,7 +318,7 @@ namespace cds { namespace container { Bar bar; myQueue.dequeue_with( [&bar]( Foo& src ) { bar = std::move( src );}); \endcode - The functor is called only is the queue is not empty. + The functor is called only if the queue is not empty. */ template bool dequeue_with( Func f ) @@ -334,19 +332,7 @@ namespace cds { namespace container { return false; } - /// Dequeues a value from the queue - /** - If queue is not empty, the function returns \p true, \p dest contains copy of - dequeued value. The assignment operator for type \ref value_type is invoked. - If queue is empty, the function returns \p false, \p dest is unchanged. - */ - bool dequeue( value_type& dest ) - { - typedef cds::details::trivial_assign functor; - return dequeue( dest, functor() ); - } - - /// Synonym for \ref dequeue function + /// Synonym for \p dequeue() function bool pop( value_type& dest ) { return dequeue( dest ); @@ -359,19 +345,31 @@ namespace cds { namespace container { return dequeue_with( f ); } + /// Clear the queue + /** + The function repeatedly calls \ref dequeue until it returns \p nullptr. + */ + void clear() + { + base_class::clear(); + } + /// Checks if the queue is empty bool empty() const { return base_class::empty(); } - /// Clear the queue - /** - The function repeatedly calls \ref dequeue until it returns \p nullptr. - */ - void clear() + /// Returns queue's item count (see \ref intrusive::MSQueue::size for explanation) + size_t size() const { - base_class::clear(); + return base_class::size(); + } + + /// Returns reference to internal statistics + const stat& statistics() const + { + return base_class::statistics(); } }; diff --git a/cds/intrusive/msqueue.h b/cds/intrusive/msqueue.h index 83fd71bb..9a81f3a0 100644 --- a/cds/intrusive/msqueue.h +++ b/cds/intrusive/msqueue.h @@ -457,25 +457,6 @@ namespace cds { namespace intrusive { dispose_node( pHead ); } - /// Returns queue's item count - /** - The value returned depends on \p msqueue::traits::item_counter. For \p atomicity::empty_item_counter, - this function always returns 0. - - @note Even if you use real item counter and it returns 0, this fact is not mean that the queue - is empty. To check queue emptyness use \p empty() method. - */ - size_t size() const - { - return m_ItemCounter.value(); - } - - /// Returns reference to internal statistics - stat const& statistics() const - { - return m_Stat; - } - /// Enqueues \p val value into the queue. /** @anchor cds_intrusive_MSQueue_enqueue The function always returns \p true. @@ -580,6 +561,26 @@ namespace cds { namespace intrusive { { while ( dequeue() ); } + + /// Returns queue's item count + /** + The value returned depends on \p msqueue::traits::item_counter. For \p atomicity::empty_item_counter, + this function always returns 0. + + @note Even if you use real item counter and it returns 0, this fact is not mean that the queue + is empty. To check queue emptyness use \p empty() method. + */ + size_t size() const + { + return m_ItemCounter.value(); + } + + /// Returns reference to internal statistics + stat const& statistics() const + { + return m_Stat; + } + }; }} // namespace cds::intrusive diff --git a/change.log b/change.log index acc33a43..5e4ee2ed 100644 --- a/change.log +++ b/change.log @@ -4,6 +4,8 @@ - Removed: MichaelDeque, reason: the implementation is heavy-weighted, inefficient, and, seems, unstable. - Added: cds::container::TreiberStack::pop_with( Func ) + - Added: member functions enqueue_with(Func), dequeue_with(Func) to cds::container::MSQueue, + cds::container::MoirQueue. 1.6.0 23.09.2014 General release diff --git a/projects/Win/vc12/hdr-test-queue.vcxproj b/projects/Win/vc12/hdr-test-queue.vcxproj index bd7fd32a..72ea162d 100644 --- a/projects/Win/vc12/hdr-test-queue.vcxproj +++ b/projects/Win/vc12/hdr-test-queue.vcxproj @@ -553,27 +553,26 @@ - - - - - - + + + + + - + + - diff --git a/projects/Win/vc12/hdr-test-queue.vcxproj.filters b/projects/Win/vc12/hdr-test-queue.vcxproj.filters index 5ad56ba4..67800298 100644 --- a/projects/Win/vc12/hdr-test-queue.vcxproj.filters +++ b/projects/Win/vc12/hdr-test-queue.vcxproj.filters @@ -49,24 +49,6 @@ intrusive - - container - - - container - - - container - - - container - - - container - - - container - container @@ -85,15 +67,25 @@ container - - container - intrusive intrusive + + container + + + container + + + container + + + container + + @@ -111,7 +103,10 @@ container - + + container + + container diff --git a/projects/source.test-hdr.mk b/projects/source.test-hdr.mk index bb3fe0c0..a542c5bb 100644 --- a/projects/source.test-hdr.mk +++ b/projects/source.test-hdr.mk @@ -116,6 +116,7 @@ CDS_TESTHDR_PQUEUE := \ tests/test-hdr/priority_queue/hdr_priority_queue_reg.cpp CDS_TESTHDR_QUEUE := \ + tests/test-hdr/queue/hdr_queue_register.cpp \ tests/test-hdr/queue/hdr_intrusive_basketqueue_hrc.cpp \ tests/test-hdr/queue/hdr_intrusive_fcqueue.cpp \ tests/test-hdr/queue/hdr_intrusive_segmented_queue_hp.cpp \ @@ -126,17 +127,16 @@ CDS_TESTHDR_QUEUE := \ 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_hzp.cpp \ - tests/test-hdr/queue/hdr_moirqueue_ptb.cpp \ - tests/test-hdr/queue/hdr_msqueue_hzp.cpp \ - tests/test-hdr/queue/hdr_msqueue_ptb.cpp \ + tests/test-hdr/queue/hdr_moirqueue_hp.cpp \ + 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_rwqueue.cpp \ tests/test-hdr/queue/hdr_segmented_queue_hp.cpp \ tests/test-hdr/queue/hdr_segmented_queue_ptb.cpp \ - tests/test-hdr/queue/hdr_vyukov_mpmc_cyclic.cpp \ - tests/test-hdr/queue/queue_test_header.cpp + tests/test-hdr/queue/hdr_vyukov_mpmc_cyclic.cpp CDS_TESTHDR_SET := \ tests/test-hdr/set/hdr_intrusive_michael_set_hrc.cpp \ diff --git a/tests/test-hdr/queue/hdr_basketqueue_hrc.cpp b/tests/test-hdr/queue/hdr_basketqueue_hrc.cpp index 4e2a8156..bf5f8835 100644 --- a/tests/test-hdr/queue/hdr_basketqueue_hrc.cpp +++ b/tests/test-hdr/queue/hdr_basketqueue_hrc.cpp @@ -3,7 +3,7 @@ #include #include -#include "queue/queue_test_header.h" +#include "queue/hdr_queue.h" namespace queue { diff --git a/tests/test-hdr/queue/hdr_basketqueue_hzp.cpp b/tests/test-hdr/queue/hdr_basketqueue_hzp.cpp index 7485a6fc..d9a9955f 100644 --- a/tests/test-hdr/queue/hdr_basketqueue_hzp.cpp +++ b/tests/test-hdr/queue/hdr_basketqueue_hzp.cpp @@ -3,7 +3,7 @@ #include #include -#include "queue/queue_test_header.h" +#include "queue/hdr_queue.h" namespace queue { diff --git a/tests/test-hdr/queue/hdr_basketqueue_ptb.cpp b/tests/test-hdr/queue/hdr_basketqueue_ptb.cpp index 10a18768..4fd1296f 100644 --- a/tests/test-hdr/queue/hdr_basketqueue_ptb.cpp +++ b/tests/test-hdr/queue/hdr_basketqueue_ptb.cpp @@ -3,7 +3,7 @@ #include #include -#include "queue/queue_test_header.h" +#include "queue/hdr_queue.h" namespace queue { diff --git a/tests/test-hdr/queue/hdr_fcqueue.cpp b/tests/test-hdr/queue/hdr_fcqueue.cpp index ec76558d..4f00f9ae 100644 --- a/tests/test-hdr/queue/hdr_fcqueue.cpp +++ b/tests/test-hdr/queue/hdr_fcqueue.cpp @@ -1,7 +1,7 @@ //$$CDS-header$$ #include -#include "queue/queue_test_header.h" +#include "queue/hdr_queue.h" #include diff --git a/tests/test-hdr/queue/hdr_intrusive_msqueue_hp.cpp b/tests/test-hdr/queue/hdr_intrusive_msqueue_hp.cpp index 9155ece6..579efdd0 100644 --- a/tests/test-hdr/queue/hdr_intrusive_msqueue_hp.cpp +++ b/tests/test-hdr/queue/hdr_intrusive_msqueue_hp.cpp @@ -188,4 +188,3 @@ namespace queue { TEST(MSQueue_HP_member_cachealign) } -CPPUNIT_TEST_SUITE_REGISTRATION(queue::IntrusiveQueueHeaderTest); diff --git a/tests/test-hdr/queue/hdr_intrusive_segmented_queue_hp.cpp b/tests/test-hdr/queue/hdr_intrusive_segmented_queue_hp.cpp index 41264b72..f22d7d3c 100644 --- a/tests/test-hdr/queue/hdr_intrusive_segmented_queue_hp.cpp +++ b/tests/test-hdr/queue/hdr_intrusive_segmented_queue_hp.cpp @@ -57,5 +57,3 @@ namespace queue { } } // namespace queue - -CPPUNIT_TEST_SUITE_REGISTRATION(queue::HdrIntrusiveSegmentedQueue); diff --git a/tests/test-hdr/queue/hdr_moirqueue_dhp.cpp b/tests/test-hdr/queue/hdr_moirqueue_dhp.cpp new file mode 100644 index 00000000..5c805c0b --- /dev/null +++ b/tests/test-hdr/queue/hdr_moirqueue_dhp.cpp @@ -0,0 +1,120 @@ +//$$CDS-header$$ + +#include +#include +#include "queue/hdr_queue_new.h" + +namespace queue { + + void HdrTestQueue::MoirQueue_DHP() + { + typedef cds::container::MoirQueue< cds::gc::DHP, int > test_queue; + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_Counted() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter < cds::atomicity::item_counter > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_relax() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::relaxed_ordering > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_Counted_relax() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model < cds::opt::v::relaxed_ordering > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_seqcst() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_Counted_seqcst() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_relax_align() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model< cds::opt::v::relaxed_ordering> + , cds::opt::alignment < 16 > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_Counted_relax_align() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model< cds::opt::v::relaxed_ordering> + , cds::opt::alignment < 32 > + >::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_seqcst_align() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model< cds::opt::v::sequential_consistent> + ,cds::opt::alignment < cds::opt::no_special_alignment > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_DHP_Counted_seqcst_align() + { + typedef cds::container::MoirQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model< cds::opt::v::sequential_consistent> + , cds::opt::alignment < cds::opt::cache_line_alignment > + > ::type + > test_queue; + test_ic< test_queue >(); + } +} // namespace queue diff --git a/tests/test-hdr/queue/hdr_moirqueue_hp.cpp b/tests/test-hdr/queue/hdr_moirqueue_hp.cpp new file mode 100644 index 00000000..86f5083a --- /dev/null +++ b/tests/test-hdr/queue/hdr_moirqueue_hp.cpp @@ -0,0 +1,121 @@ +//$$CDS-header$$ + +#include +#include + +#include "queue/hdr_queue_new.h" + +namespace queue { + + void HdrTestQueue::MoirQueue_HP() + { + typedef cds::container::MoirQueue< cds::gc::HP, int > test_queue; + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_Counted() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter < cds::atomicity::item_counter > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_relax() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::relaxed_ordering > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_Counted_relax() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model < cds::opt::v::relaxed_ordering > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_seqcst() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_Counted_seqcst() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_relax_align() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model< cds::opt::v::relaxed_ordering> + , cds::opt::alignment < 16 > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_Counted_relax_align() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model< cds::opt::v::relaxed_ordering> + , cds::opt::alignment < 32 > + >::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_seqcst_align() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model< cds::opt::v::sequential_consistent> + ,cds::opt::alignment < cds::opt::no_special_alignment > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MoirQueue_HP_Counted_seqcst_align() + { + typedef cds::container::MoirQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model< cds::opt::v::sequential_consistent> + , cds::opt::alignment < cds::opt::cache_line_alignment > + > ::type + > test_queue; + test_ic< test_queue >(); + } +} // namespace queue diff --git a/tests/test-hdr/queue/hdr_moirqueue_hrc.cpp b/tests/test-hdr/queue/hdr_moirqueue_hrc.cpp deleted file mode 100644 index aca82e26..00000000 --- a/tests/test-hdr/queue/hdr_moirqueue_hrc.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//$$CDS-header$$ - -#include -#include - -#include "queue/queue_test_header.h" - -namespace queue { - - void Queue_TestHeader::MoirQueue_HRC() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_Counted() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_relax() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_Counted_relax() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_seqcst() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_Counted_seqcst() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_relax_align() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 16 > - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_Counted_relax_align() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 32 > - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_seqcst_align() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::no_special_alignment > - > - >(); - } - - void Queue_TestHeader::MoirQueue_HRC_Counted_seqcst_align() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::cache_line_alignment > - > - >(); - } - -} // namespace queue diff --git a/tests/test-hdr/queue/hdr_moirqueue_hzp.cpp b/tests/test-hdr/queue/hdr_moirqueue_hzp.cpp deleted file mode 100644 index f4560d85..00000000 --- a/tests/test-hdr/queue/hdr_moirqueue_hzp.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//$$CDS-header$$ - -#include -#include - -#include "queue/queue_test_header.h" - -namespace queue { - - void Queue_TestHeader::MoirQueue_HP() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_Counted() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_relax() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_Counted_relax() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_seqcst() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_Counted_seqcst() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_relax_align() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 16 > - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_Counted_relax_align() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 32 > - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_seqcst_align() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::no_special_alignment > - > - >(); - } - - void Queue_TestHeader::MoirQueue_HP_Counted_seqcst_align() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::cache_line_alignment > - > - >(); - } - -} // namespace queue diff --git a/tests/test-hdr/queue/hdr_moirqueue_ptb.cpp b/tests/test-hdr/queue/hdr_moirqueue_ptb.cpp deleted file mode 100644 index dccfc3da..00000000 --- a/tests/test-hdr/queue/hdr_moirqueue_ptb.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//$$CDS-header$$ - -#include -#include - -#include "queue/queue_test_header.h" - -namespace queue { - - void Queue_TestHeader::MoirQueue_PTB() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_Counted() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_relax() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_Counted_relax() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_seqcst() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_Counted_seqcst() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_relax_align() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 16 > - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_Counted_relax_align() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 32 > - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_seqcst_align() - { - testNoItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::no_special_alignment > - > - >(); - } - - void Queue_TestHeader::MoirQueue_PTB_Counted_seqcst_align() - { - testWithItemCounter< - cds::container::MoirQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::cache_line_alignment > - > - >(); - } - -} // namespace queue diff --git a/tests/test-hdr/queue/hdr_msqueue_dhp.cpp b/tests/test-hdr/queue/hdr_msqueue_dhp.cpp new file mode 100644 index 00000000..82671315 --- /dev/null +++ b/tests/test-hdr/queue/hdr_msqueue_dhp.cpp @@ -0,0 +1,121 @@ +//$$CDS-header$$ + +#include +#include + +#include "queue/hdr_queue_new.h" + +namespace queue { + + void HdrTestQueue::MSQueue_DHP() + { + typedef cds::container::MSQueue< cds::gc::DHP, int > test_queue; + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_Counted() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter < cds::atomicity::item_counter > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_relax() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::relaxed_ordering > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_Counted_relax() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model < cds::opt::v::relaxed_ordering > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_seqcst() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_Counted_seqcst() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_relax_align() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model< cds::opt::v::relaxed_ordering> + , cds::opt::alignment < 16 > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_Counted_relax_align() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model< cds::opt::v::relaxed_ordering> + , cds::opt::alignment < 32 > + >::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_seqcst_align() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model< cds::opt::v::sequential_consistent> + ,cds::opt::alignment < cds::opt::no_special_alignment > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_DHP_Counted_seqcst_align() + { + typedef cds::container::MSQueue < cds::gc::DHP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model< cds::opt::v::sequential_consistent> + , cds::opt::alignment < cds::opt::cache_line_alignment > + > ::type + > test_queue; + test_ic< test_queue >(); + } +} // namespace queue diff --git a/tests/test-hdr/queue/hdr_msqueue_hp.cpp b/tests/test-hdr/queue/hdr_msqueue_hp.cpp new file mode 100644 index 00000000..0fd442b4 --- /dev/null +++ b/tests/test-hdr/queue/hdr_msqueue_hp.cpp @@ -0,0 +1,121 @@ +//$$CDS-header$$ + +#include +#include + +#include "queue/hdr_queue_new.h" + +namespace queue { + + void HdrTestQueue::MSQueue_HP() + { + typedef cds::container::MSQueue< cds::gc::HP, int > test_queue; + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_Counted() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter < cds::atomicity::item_counter > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_relax() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::relaxed_ordering > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_Counted_relax() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model < cds::opt::v::relaxed_ordering > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_seqcst() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_Counted_seqcst() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model < cds::opt::v::sequential_consistent > + > ::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_relax_align() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model< cds::opt::v::relaxed_ordering> + , cds::opt::alignment < 16 > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_Counted_relax_align() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model< cds::opt::v::relaxed_ordering> + , cds::opt::alignment < 32 > + >::type + > test_queue; + + test_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_seqcst_align() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::memory_model< cds::opt::v::sequential_consistent> + ,cds::opt::alignment < cds::opt::no_special_alignment > + > ::type + > test_queue; + + test_no_ic< test_queue >(); + } + + void HdrTestQueue::MSQueue_HP_Counted_seqcst_align() + { + typedef cds::container::MSQueue < cds::gc::HP, int, + typename cds::container::msqueue::make_traits < + cds::opt::item_counter< cds::atomicity::item_counter > + , cds::opt::memory_model< cds::opt::v::sequential_consistent> + , cds::opt::alignment < cds::opt::cache_line_alignment > + > ::type + > test_queue; + test_ic< test_queue >(); + } +} // namespace queue diff --git a/tests/test-hdr/queue/hdr_msqueue_hrc.cpp b/tests/test-hdr/queue/hdr_msqueue_hrc.cpp deleted file mode 100644 index a8883c30..00000000 --- a/tests/test-hdr/queue/hdr_msqueue_hrc.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//$$CDS-header$$ - -#include -#include - -#include "queue/queue_test_header.h" - -namespace queue { - - void Queue_TestHeader::MSQueue_HRC() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_Counted() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_relax() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_Counted_relax() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_seqcst() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_Counted_seqcst() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_relax_align() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 16 > - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_Counted_relax_align() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 32 > - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_seqcst_align() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::no_special_alignment > - > - >(); - } - - void Queue_TestHeader::MSQueue_HRC_Counted_seqcst_align() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HRC, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::cache_line_alignment > - > - >(); - } - -} // namespace queue diff --git a/tests/test-hdr/queue/hdr_msqueue_hzp.cpp b/tests/test-hdr/queue/hdr_msqueue_hzp.cpp deleted file mode 100644 index 72557ae3..00000000 --- a/tests/test-hdr/queue/hdr_msqueue_hzp.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//$$CDS-header$$ - -#include -#include - -#include "queue/queue_test_header.h" - -namespace queue { - - void Queue_TestHeader::MSQueue_HP() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HP, int - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_Counted() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_relax() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_Counted_relax() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_seqcst() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_Counted_seqcst() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_relax_align() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 16 > - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_Counted_relax_align() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 32 > - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_seqcst_align() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::no_special_alignment > - > - >(); - } - - void Queue_TestHeader::MSQueue_HP_Counted_seqcst_align() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::HP, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::cache_line_alignment > - > - >(); - } - -} // namespace queue diff --git a/tests/test-hdr/queue/hdr_msqueue_ptb.cpp b/tests/test-hdr/queue/hdr_msqueue_ptb.cpp deleted file mode 100644 index d0dbb6af..00000000 --- a/tests/test-hdr/queue/hdr_msqueue_ptb.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//$$CDS-header$$ - -#include -#include - -#include "queue/queue_test_header.h" - -namespace queue { - - void Queue_TestHeader::MSQueue_PTB() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_Counted() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_relax() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_Counted_relax() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_seqcst() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_Counted_seqcst() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_relax_align() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 16 > - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_Counted_relax_align() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::relaxed_ordering> - ,cds::opt::alignment< 32 > - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_seqcst_align() - { - testNoItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::no_special_alignment > - > - >(); - } - - void Queue_TestHeader::MSQueue_PTB_Counted_seqcst_align() - { - testWithItemCounter< - cds::container::MSQueue< cds::gc::PTB, int - ,cds::opt::item_counter< cds::atomicity::item_counter > - ,cds::opt::memory_model< cds::opt::v::sequential_consistent> - ,cds::opt::alignment< cds::opt::cache_line_alignment > - > - >(); - } - -} // namespace queue diff --git a/tests/test-hdr/queue/hdr_optimistic_hzp.cpp b/tests/test-hdr/queue/hdr_optimistic_hzp.cpp index 31c4db81..250fd06a 100644 --- a/tests/test-hdr/queue/hdr_optimistic_hzp.cpp +++ b/tests/test-hdr/queue/hdr_optimistic_hzp.cpp @@ -3,7 +3,7 @@ #include #include -#include "queue/queue_test_header.h" +#include "queue/hdr_queue.h" namespace queue { diff --git a/tests/test-hdr/queue/hdr_optimistic_ptb.cpp b/tests/test-hdr/queue/hdr_optimistic_ptb.cpp index a1fa4ee4..0a89daa2 100644 --- a/tests/test-hdr/queue/hdr_optimistic_ptb.cpp +++ b/tests/test-hdr/queue/hdr_optimistic_ptb.cpp @@ -3,7 +3,7 @@ #include #include -#include "queue/queue_test_header.h" +#include "queue/hdr_queue.h" namespace queue { diff --git a/tests/test-hdr/queue/queue_test_header.h b/tests/test-hdr/queue/hdr_queue.h similarity index 76% rename from tests/test-hdr/queue/queue_test_header.h rename to tests/test-hdr/queue/hdr_queue.h index bd374fd4..2023d420 100644 --- a/tests/test-hdr/queue/queue_test_header.h +++ b/tests/test-hdr/queue/hdr_queue.h @@ -150,27 +150,16 @@ namespace queue { void MSQueue_HP_Counted_relax_align(); void MSQueue_HP_Counted_seqcst_align(); - void MSQueue_HRC(); - void MSQueue_HRC_relax(); - void MSQueue_HRC_seqcst(); - void MSQueue_HRC_relax_align(); - void MSQueue_HRC_seqcst_align(); - void MSQueue_HRC_Counted(); - void MSQueue_HRC_Counted_relax(); - void MSQueue_HRC_Counted_seqcst(); - void MSQueue_HRC_Counted_relax_align(); - void MSQueue_HRC_Counted_seqcst_align(); - - void MSQueue_PTB(); - void MSQueue_PTB_relax(); - void MSQueue_PTB_seqcst(); - void MSQueue_PTB_relax_align(); - void MSQueue_PTB_seqcst_align(); - void MSQueue_PTB_Counted(); - void MSQueue_PTB_Counted_relax(); - void MSQueue_PTB_Counted_seqcst(); - void MSQueue_PTB_Counted_relax_align(); - void MSQueue_PTB_Counted_seqcst_align(); + void MSQueue_DHP(); + void MSQueue_DHP_relax(); + void MSQueue_DHP_seqcst(); + void MSQueue_DHP_relax_align(); + void MSQueue_DHP_seqcst_align(); + void MSQueue_DHP_Counted(); + void MSQueue_DHP_Counted_relax(); + void MSQueue_DHP_Counted_seqcst(); + void MSQueue_DHP_Counted_relax_align(); + void MSQueue_DHP_Counted_seqcst_align(); void MoirQueue_HP(); void MoirQueue_HP_relax(); @@ -183,27 +172,16 @@ namespace queue { void MoirQueue_HP_Counted_relax_align(); void MoirQueue_HP_Counted_seqcst_align(); - void MoirQueue_HRC(); - void MoirQueue_HRC_relax(); - void MoirQueue_HRC_seqcst(); - void MoirQueue_HRC_relax_align(); - void MoirQueue_HRC_seqcst_align(); - void MoirQueue_HRC_Counted(); - void MoirQueue_HRC_Counted_relax(); - void MoirQueue_HRC_Counted_seqcst(); - void MoirQueue_HRC_Counted_relax_align(); - void MoirQueue_HRC_Counted_seqcst_align(); - - void MoirQueue_PTB(); - void MoirQueue_PTB_relax(); - void MoirQueue_PTB_seqcst(); - void MoirQueue_PTB_relax_align(); - void MoirQueue_PTB_seqcst_align(); - void MoirQueue_PTB_Counted(); - void MoirQueue_PTB_Counted_relax(); - void MoirQueue_PTB_Counted_seqcst(); - void MoirQueue_PTB_Counted_relax_align(); - void MoirQueue_PTB_Counted_seqcst_align(); + void MoirQueue_DHP(); + void MoirQueue_DHP_relax(); + void MoirQueue_DHP_seqcst(); + void MoirQueue_DHP_relax_align(); + void MoirQueue_DHP_seqcst_align(); + void MoirQueue_DHP_Counted(); + void MoirQueue_DHP_Counted_relax(); + void MoirQueue_DHP_Counted_seqcst(); + void MoirQueue_DHP_Counted_relax_align(); + void MoirQueue_DHP_Counted_seqcst_align(); void OptimisticQueue_HP(); void OptimisticQueue_HP_relax(); @@ -287,27 +265,16 @@ namespace queue { CPPUNIT_TEST(MSQueue_HP_Counted_relax_align); CPPUNIT_TEST(MSQueue_HP_Counted_seqcst_align); - CPPUNIT_TEST(MSQueue_HRC); - CPPUNIT_TEST(MSQueue_HRC_relax); - CPPUNIT_TEST(MSQueue_HRC_seqcst); - CPPUNIT_TEST(MSQueue_HRC_relax_align); - CPPUNIT_TEST(MSQueue_HRC_seqcst_align); - CPPUNIT_TEST(MSQueue_HRC_Counted); - CPPUNIT_TEST(MSQueue_HRC_Counted_relax); - CPPUNIT_TEST(MSQueue_HRC_Counted_seqcst); - CPPUNIT_TEST(MSQueue_HRC_Counted_relax_align); - CPPUNIT_TEST(MSQueue_HRC_Counted_seqcst_align); - - CPPUNIT_TEST(MSQueue_PTB); - CPPUNIT_TEST(MSQueue_PTB_relax); - CPPUNIT_TEST(MSQueue_PTB_seqcst); - CPPUNIT_TEST(MSQueue_PTB_relax_align); - CPPUNIT_TEST(MSQueue_PTB_seqcst_align); - CPPUNIT_TEST(MSQueue_PTB_Counted); - CPPUNIT_TEST(MSQueue_PTB_Counted_relax); - CPPUNIT_TEST(MSQueue_PTB_Counted_seqcst); - CPPUNIT_TEST(MSQueue_PTB_Counted_relax_align); - CPPUNIT_TEST(MSQueue_PTB_Counted_seqcst_align); + CPPUNIT_TEST(MSQueue_DHP); + CPPUNIT_TEST(MSQueue_DHP_relax); + CPPUNIT_TEST(MSQueue_DHP_seqcst); + CPPUNIT_TEST(MSQueue_DHP_relax_align); + CPPUNIT_TEST(MSQueue_DHP_seqcst_align); + CPPUNIT_TEST(MSQueue_DHP_Counted); + CPPUNIT_TEST(MSQueue_DHP_Counted_relax); + CPPUNIT_TEST(MSQueue_DHP_Counted_seqcst); + CPPUNIT_TEST(MSQueue_DHP_Counted_relax_align); + CPPUNIT_TEST(MSQueue_DHP_Counted_seqcst_align); CPPUNIT_TEST(MoirQueue_HP); CPPUNIT_TEST(MoirQueue_HP_relax); @@ -320,27 +287,16 @@ namespace queue { CPPUNIT_TEST(MoirQueue_HP_Counted_relax_align); CPPUNIT_TEST(MoirQueue_HP_Counted_seqcst_align); - CPPUNIT_TEST(MoirQueue_HRC); - CPPUNIT_TEST(MoirQueue_HRC_relax); - CPPUNIT_TEST(MoirQueue_HRC_seqcst); - CPPUNIT_TEST(MoirQueue_HRC_relax_align); - CPPUNIT_TEST(MoirQueue_HRC_seqcst_align); - CPPUNIT_TEST(MoirQueue_HRC_Counted); - CPPUNIT_TEST(MoirQueue_HRC_Counted_relax); - CPPUNIT_TEST(MoirQueue_HRC_Counted_seqcst); - CPPUNIT_TEST(MoirQueue_HRC_Counted_relax_align); - CPPUNIT_TEST(MoirQueue_HRC_Counted_seqcst_align); - - CPPUNIT_TEST(MoirQueue_PTB); - CPPUNIT_TEST(MoirQueue_PTB_relax); - CPPUNIT_TEST(MoirQueue_PTB_seqcst); - CPPUNIT_TEST(MoirQueue_PTB_relax_align); - CPPUNIT_TEST(MoirQueue_PTB_seqcst_align); - CPPUNIT_TEST(MoirQueue_PTB_Counted); - CPPUNIT_TEST(MoirQueue_PTB_Counted_relax); - CPPUNIT_TEST(MoirQueue_PTB_Counted_seqcst); - CPPUNIT_TEST(MoirQueue_PTB_Counted_relax_align); - CPPUNIT_TEST(MoirQueue_PTB_Counted_seqcst_align); + CPPUNIT_TEST(MoirQueue_DHP); + CPPUNIT_TEST(MoirQueue_DHP_relax); + CPPUNIT_TEST(MoirQueue_DHP_seqcst); + CPPUNIT_TEST(MoirQueue_DHP_relax_align); + CPPUNIT_TEST(MoirQueue_DHP_seqcst_align); + CPPUNIT_TEST(MoirQueue_DHP_Counted); + CPPUNIT_TEST(MoirQueue_DHP_Counted_relax); + CPPUNIT_TEST(MoirQueue_DHP_Counted_seqcst); + CPPUNIT_TEST(MoirQueue_DHP_Counted_relax_align); + CPPUNIT_TEST(MoirQueue_DHP_Counted_seqcst_align); CPPUNIT_TEST(OptimisticQueue_HP); CPPUNIT_TEST(OptimisticQueue_HP_relax); diff --git a/tests/test-hdr/queue/hdr_queue_new.h b/tests/test-hdr/queue/hdr_queue_new.h new file mode 100644 index 00000000..cde550a8 --- /dev/null +++ b/tests/test-hdr/queue/hdr_queue_new.h @@ -0,0 +1,417 @@ +//$$CDS-header$$ + +#ifndef __CDSUNIT_QUEUE_HDR_H +#define __CDSUNIT_QUEUE_HDR_H + +#include "cppunit/cppunit_proxy.h" +#include + +namespace queue { + + // + // Test queue operation in single thread mode + // + class HdrTestQueue: public CppUnitMini::TestCase + { + protected: + template + void test_no_ic() + { + Queue q; + test_with( q ); + test_emplace( q ); + } + + template + void test_with( Queue& q ) + { + int it; + int nPrev; + + // push/pop + for ( size_t i = 0; i < 3; ++i ) { + CPPUNIT_ASSERT( q.empty() ); +#ifndef _DEBUG + CPPUNIT_ASSERT( q.size() == 0 ); +#endif + CPPUNIT_ASSERT( q.enqueue( 1 ) ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.push( 10 ) ); + CPPUNIT_ASSERT( !q.empty() ); +#ifndef _DEBUG + CPPUNIT_ASSERT( q.size() == 0 ) ; // no queue's item counter! +#endif + + it = -1; + CPPUNIT_ASSERT( q.pop( it ) ); + CPPUNIT_ASSERT( it == 1 ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.dequeue( it ) ); + CPPUNIT_ASSERT( it == 10 ); +#ifndef _DEBUG + CPPUNIT_ASSERT( q.size() == 0 ); +#endif + CPPUNIT_ASSERT( q.empty() ); + it += 2009; + nPrev = it; + CPPUNIT_ASSERT( !q.dequeue( it ) ); + CPPUNIT_ASSERT( it == nPrev ) ; // it must not be changed! + } + + // push_with/pop_with + for ( size_t i = 0; i < 3; ++i ) { + CPPUNIT_ASSERT( q.empty() ); +#ifndef _DEBUG + CPPUNIT_ASSERT( q.size() == 0 ); +#endif + CPPUNIT_ASSERT( q.enqueue_with( []( int& dest ) { dest = 1; } )); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.push_with( []( int& dest ) { dest = 10; } )); + CPPUNIT_ASSERT( !q.empty() ); +#ifndef _DEBUG + CPPUNIT_ASSERT( q.size() == 0 ); // no queue's item counter! +#endif + + it = -1; + CPPUNIT_ASSERT( q.pop_with( [&it]( int src ) { it = src; } )); + CPPUNIT_ASSERT( it == 1 ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.dequeue_with( [&it]( int src ) { it = src; } )); + CPPUNIT_ASSERT( it == 10 ); +#ifndef _DEBUG + CPPUNIT_ASSERT( q.size() == 0 ); +#endif + CPPUNIT_ASSERT( q.empty() ); + it += 2009; + nPrev = it; + CPPUNIT_ASSERT( !q.dequeue_with( [&it]( int src ) { it = src; } )); + CPPUNIT_ASSERT( it == nPrev ); // it must not be changed! + } + } + + template + void test_emplace( Queue& q ) + { + int it; + for ( size_t i = 0; i < 3; ++i ) { + CPPUNIT_ASSERT( q.emplace( static_cast( i * 42 )) ); + CPPUNIT_ASSERT( !q.empty() ); + it = -1; + CPPUNIT_ASSERT( q.pop( it )); + CPPUNIT_ASSERT( it == static_cast( i * 42 )); + CPPUNIT_ASSERT( q.empty() ); + } + } + + template + void test_ic() + { + Queue q; + test_ic_with( q ); + test_emplace_ic( q ); + } + + template + void testFCQueue() + { + Queue q; + test_ic_with( q ); + } + + template + void test_ic_with( Queue& q ) + { + int it; + int nPrev; + + // push/pop + for ( size_t i = 0; i < 3; ++i ) { + CPPUNIT_ASSERT( q.empty() ); + CPPUNIT_ASSERT( q.size() == 0 ); + CPPUNIT_ASSERT( q.enqueue( 1 ) ); + CPPUNIT_ASSERT( q.size() == 1 ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.push( 10 ) ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.size() == 2 ); + + it = -1; + CPPUNIT_ASSERT( q.pop( it ) ); + CPPUNIT_ASSERT( it == 1 ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.size() == 1 ); + CPPUNIT_ASSERT( q.dequeue( it ) ); + CPPUNIT_ASSERT( it == 10 ); + CPPUNIT_ASSERT( q.size() == 0 ); + CPPUNIT_ASSERT( q.empty() ); + CPPUNIT_ASSERT( q.size() == 0 ); + it += 2009; + nPrev = it; + CPPUNIT_ASSERT( !q.dequeue( it ) ); + CPPUNIT_ASSERT( it == nPrev ) ; // it must not be changed! + + CPPUNIT_ASSERT( q.empty() ); + CPPUNIT_ASSERT( q.size() == 0 ); + } + + // push_with/pop_with + for ( size_t i = 0; i < 3; ++i ) { + CPPUNIT_ASSERT( q.empty() ); + CPPUNIT_ASSERT( q.size() == 0 ); + CPPUNIT_ASSERT( q.enqueue_with( []( int& dest ) { dest = 1; } ) ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.size() == 1 ); + CPPUNIT_ASSERT( q.push_with( []( int& dest ) { dest = 10; } ) ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.size() == 2 ); + + it = -1; + CPPUNIT_ASSERT( q.pop_with( [&it]( int src ) { it = src; } ) ); + CPPUNIT_ASSERT( it == 1 ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.size() == 1 ); + CPPUNIT_ASSERT( q.dequeue_with( [&it]( int src ) { it = src; } ) ); + CPPUNIT_ASSERT( it == 10 ); + CPPUNIT_ASSERT( q.size() == 0 ); + CPPUNIT_ASSERT( q.empty() ); + it += 2009; + nPrev = it; + CPPUNIT_ASSERT( !q.dequeue_with( [&it]( int src ) { it = src; } ) ); + CPPUNIT_ASSERT( it == nPrev ); // it must not be changed! + + CPPUNIT_ASSERT( q.size() == 0 ); + CPPUNIT_ASSERT( q.empty() ); + } + } + + template + void test_emplace_ic( Queue& q ) + { + int it = 0; + for ( size_t i = 0; i < 3; ++i ) { + CPPUNIT_ASSERT( q.emplace( (int) i * 10 ) ); + CPPUNIT_ASSERT( !q.empty() ); + CPPUNIT_ASSERT( q.size() == 1 ); + CPPUNIT_ASSERT( q.pop( it )); + CPPUNIT_ASSERT( it == (int) i * 10 ); + CPPUNIT_ASSERT( q.empty() ); + CPPUNIT_ASSERT( q.size() == 0 ); + } + } + + public: + void MSQueue_HP(); + void MSQueue_HP_relax(); + void MSQueue_HP_seqcst(); + void MSQueue_HP_relax_align(); + void MSQueue_HP_seqcst_align(); + void MSQueue_HP_Counted(); + void MSQueue_HP_Counted_relax(); + void MSQueue_HP_Counted_seqcst(); + void MSQueue_HP_Counted_relax_align(); + void MSQueue_HP_Counted_seqcst_align(); + + void MSQueue_DHP(); + void MSQueue_DHP_relax(); + void MSQueue_DHP_seqcst(); + void MSQueue_DHP_relax_align(); + void MSQueue_DHP_seqcst_align(); + void MSQueue_DHP_Counted(); + void MSQueue_DHP_Counted_relax(); + void MSQueue_DHP_Counted_seqcst(); + void MSQueue_DHP_Counted_relax_align(); + void MSQueue_DHP_Counted_seqcst_align(); + + void MoirQueue_HP(); + void MoirQueue_HP_relax(); + void MoirQueue_HP_seqcst(); + void MoirQueue_HP_relax_align(); + void MoirQueue_HP_seqcst_align(); + void MoirQueue_HP_Counted(); + void MoirQueue_HP_Counted_relax(); + void MoirQueue_HP_Counted_seqcst(); + void MoirQueue_HP_Counted_relax_align(); + void MoirQueue_HP_Counted_seqcst_align(); + + void MoirQueue_DHP(); + void MoirQueue_DHP_relax(); + void MoirQueue_DHP_seqcst(); + void MoirQueue_DHP_relax_align(); + void MoirQueue_DHP_seqcst_align(); + void MoirQueue_DHP_Counted(); + void MoirQueue_DHP_Counted_relax(); + void MoirQueue_DHP_Counted_seqcst(); + void MoirQueue_DHP_Counted_relax_align(); + void MoirQueue_DHP_Counted_seqcst_align(); + +/* + void OptimisticQueue_HP(); + void OptimisticQueue_HP_relax(); + void OptimisticQueue_HP_seqcst(); + void OptimisticQueue_HP_relax_align(); + void OptimisticQueue_HP_seqcst_align(); + void OptimisticQueue_HP_Counted(); + void OptimisticQueue_HP_Counted_relax(); + void OptimisticQueue_HP_Counted_seqcst(); + void OptimisticQueue_HP_Counted_relax_align(); + void OptimisticQueue_HP_Counted_seqcst_align(); + + void OptimisticQueue_DHP(); + void OptimisticQueue_DHP_relax(); + void OptimisticQueue_DHP_seqcst(); + void OptimisticQueue_DHP_relax_align(); + void OptimisticQueue_DHP_seqcst_align(); + void OptimisticQueue_DHP_Counted(); + void OptimisticQueue_DHP_Counted_relax(); + void OptimisticQueue_DHP_Counted_seqcst(); + void OptimisticQueue_DHP_Counted_relax_align(); + void OptimisticQueue_DHP_Counted_seqcst_align(); + + void BasketQueue_HP(); + void BasketQueue_HP_relax(); + void BasketQueue_HP_seqcst(); + void BasketQueue_HP_relax_align(); + void BasketQueue_HP_seqcst_align(); + void BasketQueue_HP_Counted(); + void BasketQueue_HP_Counted_relax(); + void BasketQueue_HP_Counted_seqcst(); + void BasketQueue_HP_Counted_relax_align(); + void BasketQueue_HP_Counted_seqcst_align(); + + void BasketQueue_DHP(); + void BasketQueue_DHP_relax(); + void BasketQueue_DHP_seqcst(); + void BasketQueue_DHP_relax_align(); + void BasketQueue_DHP_seqcst_align(); + void BasketQueue_DHP_Counted(); + void BasketQueue_DHP_Counted_relax(); + void BasketQueue_DHP_Counted_seqcst(); + void BasketQueue_DHP_Counted_relax_align(); + void BasketQueue_DHP_Counted_seqcst_align(); + + void FCQueue_deque(); + void FCQueue_deque_elimination(); + void FCQueue_deque_mutex(); + void FCQueue_deque_stat(); + void FCQueue_list(); + void FCQueue_list_elimination(); + void FCQueue_list_mutex(); + void FCQueue_list_stat(); + + void Vyukov_MPMCCyclicQueue(); + void Vyukov_MPMCCyclicQueue_Counted(); + + void RWQueue_(); + void RWQueue_Counted(); +*/ + + CPPUNIT_TEST_SUITE( HdrTestQueue ) + CPPUNIT_TEST(MSQueue_HP); + CPPUNIT_TEST(MSQueue_HP_relax); + CPPUNIT_TEST(MSQueue_HP_seqcst); + CPPUNIT_TEST(MSQueue_HP_relax_align); + CPPUNIT_TEST(MSQueue_HP_seqcst_align); + CPPUNIT_TEST(MSQueue_HP_Counted); + CPPUNIT_TEST(MSQueue_HP_Counted_relax); + CPPUNIT_TEST(MSQueue_HP_Counted_seqcst); + CPPUNIT_TEST(MSQueue_HP_Counted_relax_align); + CPPUNIT_TEST(MSQueue_HP_Counted_seqcst_align); + + CPPUNIT_TEST(MSQueue_DHP); + CPPUNIT_TEST(MSQueue_DHP_relax); + CPPUNIT_TEST(MSQueue_DHP_seqcst); + CPPUNIT_TEST(MSQueue_DHP_relax_align); + CPPUNIT_TEST(MSQueue_DHP_seqcst_align); + CPPUNIT_TEST(MSQueue_DHP_Counted); + CPPUNIT_TEST(MSQueue_DHP_Counted_relax); + CPPUNIT_TEST(MSQueue_DHP_Counted_seqcst); + CPPUNIT_TEST(MSQueue_DHP_Counted_relax_align); + CPPUNIT_TEST(MSQueue_DHP_Counted_seqcst_align); + + CPPUNIT_TEST(MoirQueue_HP); + CPPUNIT_TEST(MoirQueue_HP_relax); + CPPUNIT_TEST(MoirQueue_HP_seqcst); + CPPUNIT_TEST(MoirQueue_HP_relax_align); + CPPUNIT_TEST(MoirQueue_HP_seqcst_align); + CPPUNIT_TEST(MoirQueue_HP_Counted); + CPPUNIT_TEST(MoirQueue_HP_Counted_relax); + CPPUNIT_TEST(MoirQueue_HP_Counted_seqcst); + CPPUNIT_TEST(MoirQueue_HP_Counted_relax_align); + CPPUNIT_TEST(MoirQueue_HP_Counted_seqcst_align); + + CPPUNIT_TEST(MoirQueue_DHP); + CPPUNIT_TEST(MoirQueue_DHP_relax); + CPPUNIT_TEST(MoirQueue_DHP_seqcst); + CPPUNIT_TEST(MoirQueue_DHP_relax_align); + CPPUNIT_TEST(MoirQueue_DHP_seqcst_align); + CPPUNIT_TEST(MoirQueue_DHP_Counted); + CPPUNIT_TEST(MoirQueue_DHP_Counted_relax); + CPPUNIT_TEST(MoirQueue_DHP_Counted_seqcst); + CPPUNIT_TEST(MoirQueue_DHP_Counted_relax_align); + CPPUNIT_TEST(MoirQueue_DHP_Counted_seqcst_align); +/* + CPPUNIT_TEST(OptimisticQueue_HP); + CPPUNIT_TEST(OptimisticQueue_HP_relax); + CPPUNIT_TEST(OptimisticQueue_HP_seqcst); + CPPUNIT_TEST(OptimisticQueue_HP_relax_align); + CPPUNIT_TEST(OptimisticQueue_HP_seqcst_align); + CPPUNIT_TEST(OptimisticQueue_HP_Counted); + CPPUNIT_TEST(OptimisticQueue_HP_Counted_relax); + CPPUNIT_TEST(OptimisticQueue_HP_Counted_seqcst); + CPPUNIT_TEST(OptimisticQueue_HP_Counted_relax_align); + CPPUNIT_TEST(OptimisticQueue_HP_Counted_seqcst_align); + + CPPUNIT_TEST(OptimisticQueue_DHP); + CPPUNIT_TEST(OptimisticQueue_DHP_relax); + CPPUNIT_TEST(OptimisticQueue_DHP_seqcst); + CPPUNIT_TEST(OptimisticQueue_DHP_relax_align); + CPPUNIT_TEST(OptimisticQueue_DHP_seqcst_align); + CPPUNIT_TEST(OptimisticQueue_DHP_Counted); + CPPUNIT_TEST(OptimisticQueue_DHP_Counted_relax); + CPPUNIT_TEST(OptimisticQueue_DHP_Counted_seqcst); + CPPUNIT_TEST(OptimisticQueue_DHP_Counted_relax_align); + CPPUNIT_TEST(OptimisticQueue_DHP_Counted_seqcst_align); + + CPPUNIT_TEST(BasketQueue_HP); + CPPUNIT_TEST(BasketQueue_HP_relax); + CPPUNIT_TEST(BasketQueue_HP_seqcst); + CPPUNIT_TEST(BasketQueue_HP_relax_align); + CPPUNIT_TEST(BasketQueue_HP_seqcst_align); + CPPUNIT_TEST(BasketQueue_HP_Counted); + CPPUNIT_TEST(BasketQueue_HP_Counted_relax); + CPPUNIT_TEST(BasketQueue_HP_Counted_seqcst); + CPPUNIT_TEST(BasketQueue_HP_Counted_relax_align); + CPPUNIT_TEST(BasketQueue_HP_Counted_seqcst_align); + + CPPUNIT_TEST(BasketQueue_DHP); + CPPUNIT_TEST(BasketQueue_DHP_relax); + CPPUNIT_TEST(BasketQueue_DHP_seqcst); + CPPUNIT_TEST(BasketQueue_DHP_relax_align); + CPPUNIT_TEST(BasketQueue_DHP_seqcst_align); + CPPUNIT_TEST(BasketQueue_DHP_Counted); + CPPUNIT_TEST(BasketQueue_DHP_Counted_relax); + CPPUNIT_TEST(BasketQueue_DHP_Counted_seqcst); + CPPUNIT_TEST(BasketQueue_DHP_Counted_relax_align); + CPPUNIT_TEST(BasketQueue_DHP_Counted_seqcst_align); + + CPPUNIT_TEST(FCQueue_deque) + CPPUNIT_TEST(FCQueue_deque_elimination) + CPPUNIT_TEST(FCQueue_deque_mutex) + CPPUNIT_TEST(FCQueue_deque_stat) + CPPUNIT_TEST(FCQueue_list) + CPPUNIT_TEST(FCQueue_list_elimination) + CPPUNIT_TEST(FCQueue_list_mutex) + CPPUNIT_TEST(FCQueue_list_stat) + + CPPUNIT_TEST(RWQueue_); + CPPUNIT_TEST(RWQueue_Counted); + + CPPUNIT_TEST(Vyukov_MPMCCyclicQueue); + CPPUNIT_TEST(Vyukov_MPMCCyclicQueue_Counted); +*/ + CPPUNIT_TEST_SUITE_END(); + + }; +} // namespace queue + +#endif // #ifndef __CDSUNIT_QUEUE_HDR_H diff --git a/tests/test-hdr/queue/hdr_queue_register.cpp b/tests/test-hdr/queue/hdr_queue_register.cpp new file mode 100644 index 00000000..9f3e24bf --- /dev/null +++ b/tests/test-hdr/queue/hdr_queue_register.cpp @@ -0,0 +1,13 @@ +//$$CDS-header$$ + +#include "hdr_intrusive_msqueue.h" +#include "hdr_intrusive_segmented_queue.h" +#include "hdr_queue_new.h" +#include "hdr_queue.h" //TODO must be removed after refactoring +#include "hdr_segmented_queue.h" + +CPPUNIT_TEST_SUITE_REGISTRATION( queue::HdrTestQueue ); +CPPUNIT_TEST_SUITE_REGISTRATION( queue::Queue_TestHeader); //TODO must be removed after refactoring +CPPUNIT_TEST_SUITE_REGISTRATION( queue::HdrSegmentedQueue ); +CPPUNIT_TEST_SUITE_REGISTRATION( queue::IntrusiveQueueHeaderTest ); +CPPUNIT_TEST_SUITE_REGISTRATION( queue::HdrIntrusiveSegmentedQueue ); diff --git a/tests/test-hdr/queue/hdr_rwqueue.cpp b/tests/test-hdr/queue/hdr_rwqueue.cpp index c0dce8c2..5969d22f 100644 --- a/tests/test-hdr/queue/hdr_rwqueue.cpp +++ b/tests/test-hdr/queue/hdr_rwqueue.cpp @@ -2,7 +2,7 @@ #include -#include "queue/queue_test_header.h" +#include "queue/hdr_queue.h" namespace queue { void Queue_TestHeader::RWQueue_() diff --git a/tests/test-hdr/queue/hdr_segmented_queue_hp.cpp b/tests/test-hdr/queue/hdr_segmented_queue_hp.cpp index b7f411be..057df7a2 100644 --- a/tests/test-hdr/queue/hdr_segmented_queue_hp.cpp +++ b/tests/test-hdr/queue/hdr_segmented_queue_hp.cpp @@ -50,5 +50,3 @@ namespace queue { } } // namespace queue - -CPPUNIT_TEST_SUITE_REGISTRATION(queue::HdrSegmentedQueue); diff --git a/tests/test-hdr/queue/hdr_vyukov_mpmc_cyclic.cpp b/tests/test-hdr/queue/hdr_vyukov_mpmc_cyclic.cpp index 4041acbe..cd26d9e9 100644 --- a/tests/test-hdr/queue/hdr_vyukov_mpmc_cyclic.cpp +++ b/tests/test-hdr/queue/hdr_vyukov_mpmc_cyclic.cpp @@ -2,7 +2,7 @@ #include -#include "queue/queue_test_header.h" +#include "queue/hdr_queue.h" namespace queue { namespace { diff --git a/tests/test-hdr/queue/queue_test_header.cpp b/tests/test-hdr/queue/queue_test_header.cpp deleted file mode 100644 index 8a00355d..00000000 --- a/tests/test-hdr/queue/queue_test_header.cpp +++ /dev/null @@ -1,4 +0,0 @@ -//$$CDS-header$$ - -#include "queue/queue_test_header.h" -CPPUNIT_TEST_SUITE_REGISTRATION(queue::Queue_TestHeader); diff --git a/tests/unit/queue/intrusive_queue_type.h b/tests/unit/queue/intrusive_queue_type.h index ba62d5ff..825aae88 100644 --- a/tests/unit/queue/intrusive_queue_type.h +++ b/tests/unit/queue/intrusive_queue_type.h @@ -441,7 +441,7 @@ namespace std { << "\t\t Bad tail: " << s.m_BadTail.get() << "\n"; } - static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::queue_dummy_stat const& s ) + static inline std::ostream& operator <<( std::ostream& o, cds::intrusive::msqueue::empty_stat const& s ) { return o; } -- 2.34.1