X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11concurrency-benchmarks.git;a=blobdiff_plain;f=gdax-orderbook-hpp%2Fdemo%2Fdependencies%2Flibcds-2.3.2%2Ftest%2Funit%2Fintrusive-set%2Ftest_intrusive_michael_lazy_rcu.h;fp=gdax-orderbook-hpp%2Fdemo%2Fdependencies%2Flibcds-2.3.2%2Ftest%2Funit%2Fintrusive-set%2Ftest_intrusive_michael_lazy_rcu.h;h=5c036504ba11fbc8d11cb0c79587fb48fe3e3a02;hp=0000000000000000000000000000000000000000;hb=4223430d9168223029c7639149025c79e69b4f37;hpb=7ea7751a31c0388bf888052517be181a2989b113 diff --git a/gdax-orderbook-hpp/demo/dependencies/libcds-2.3.2/test/unit/intrusive-set/test_intrusive_michael_lazy_rcu.h b/gdax-orderbook-hpp/demo/dependencies/libcds-2.3.2/test/unit/intrusive-set/test_intrusive_michael_lazy_rcu.h new file mode 100644 index 0000000..5c03650 --- /dev/null +++ b/gdax-orderbook-hpp/demo/dependencies/libcds-2.3.2/test/unit/intrusive-set/test_intrusive_michael_lazy_rcu.h @@ -0,0 +1,408 @@ +/* + This file is a part of libcds - Concurrent Data Structures library + + (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017 + + Source code repo: http://github.com/khizmax/libcds/ + Download: http://sourceforge.net/projects/libcds/files/ + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef CDSUNIT_SET_TEST_INTRUSIVE_MICHAEL_LAZY_RCU_H +#define CDSUNIT_SET_TEST_INTRUSIVE_MICHAEL_LAZY_RCU_H + +#include "test_intrusive_set_rcu.h" +#include +#include + +namespace ci = cds::intrusive; + +template +class IntrusiveMichaelLazySet: public cds_test::intrusive_set_rcu +{ + typedef cds_test::intrusive_set_rcu base_class; +public: + typedef cds::urcu::gc rcu_type; + typedef typename base_class::base_int_item< ci::lazy_list::node> base_item_type; + typedef typename base_class::base_int_item< ci::lazy_list::node> base_mutex_item_type; + typedef typename base_class::member_int_item< ci::lazy_list::node> member_item_type; + typedef typename base_class::member_int_item< ci::lazy_list::node> member_mutex_item_type; + +protected: + void SetUp() + { + RCU::Construct(); + cds::threading::Manager::attachThread(); + } + + void TearDown() + { + cds::threading::Manager::detachThread(); + RCU::Destruct(); + } +}; + +TYPED_TEST_CASE_P( IntrusiveMichaelLazySet ); + +TYPED_TEST_P( IntrusiveMichaelLazySet, base_cmp ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template cmp item_cmp; + typedef typename TestFixture::hash_int hash_int; + + typedef ci::LazyList< rcu_type + , base_item_type + , typename ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< ci::opt::gc< rcu_type > > > + , ci::opt::compare< item_cmp > + , ci::opt::disposer< mock_disposer > + >::type + > bucket_type; + + typedef ci::MichaelHashSet< rcu_type, bucket_type, + typename ci::michael_set::make_traits< + ci::opt::hash< hash_int > + >::type + > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, base_less ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template less item_less; + typedef typename TestFixture::hash_int hash_int; + + typedef ci::LazyList< rcu_type + , base_item_type + , typename ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::base_hook< ci::opt::gc< rcu_type >>> + , ci::opt::less< item_less > + , ci::opt::disposer< mock_disposer > + >::type + > bucket_type; + + typedef ci::MichaelHashSet< rcu_type, bucket_type, + typename ci::michael_set::make_traits< + ci::opt::hash< hash_int > + >::type + > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, base_cmpmix ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::hash_int hash_int; + + struct list_traits : public ci::lazy_list::traits + { + typedef ci::lazy_list::base_hook< ci::opt::gc> hook; + typedef typename TestFixture::template less less; + typedef typename TestFixture::template cmp compare; + typedef mock_disposer disposer; + }; + typedef ci::LazyList< rcu_type, base_item_type, list_traits > bucket_type; + + struct set_traits : public ci::michael_set::traits + { + typedef hash_int hash; + typedef typename TestFixture::simple_item_counter item_counter; + }; + typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, base_mutex ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_mutex_item_type base_mutex_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::hash_int hash_int; + + struct list_traits : public ci::lazy_list::traits + { + typedef ci::lazy_list::base_hook< ci::opt::gc, ci::opt::lock_type> hook; + typedef typename TestFixture::template less less; + typedef typename TestFixture::template cmp compare; + typedef mock_disposer disposer; + }; + typedef ci::LazyList< rcu_type, base_mutex_item_type, list_traits > bucket_type; + + struct set_traits : public ci::michael_set::traits + { + typedef hash_int hash; + typedef typename TestFixture::simple_item_counter item_counter; + }; + typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, base_stat ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::hash_int hash_int; + + struct list_traits: public ci::lazy_list::traits + { + typedef ci::lazy_list::base_hook< ci::opt::gc> hook; + typedef typename TestFixture::template less less; + typedef mock_disposer disposer; + typedef ci::lazy_list::stat<> stat; + }; + typedef ci::LazyList< rcu_type, base_item_type, list_traits > bucket_type; + + struct set_traits: public ci::michael_set::traits + { + typedef hash_int hash; + typedef typename TestFixture::simple_item_counter item_counter; + }; + typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); + EXPECT_GE( s.statistics().m_nInsertSuccess, 0u ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, base_wrapped_stat ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::base_item_type base_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::hash_int hash_int; + + struct list_traits: public ci::lazy_list::traits + { + typedef ci::lazy_list::base_hook< ci::opt::gc> hook; + typedef typename TestFixture::template less less; + typedef mock_disposer disposer; + typedef ci::lazy_list::wrapped_stat<> stat; + }; + typedef ci::LazyList< rcu_type, base_item_type, list_traits > bucket_type; + + struct set_traits: public ci::michael_set::traits + { + typedef hash_int hash; + typedef typename TestFixture::simple_item_counter item_counter; + }; + typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); + EXPECT_GE( s.statistics().m_nInsertSuccess, 0u ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, member_cmp ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template cmp item_cmp; + typedef typename TestFixture::hash_int hash_int; + + typedef ci::LazyList< rcu_type + , member_item_type + , typename ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( member_item_type, hMember ), + ci::opt::gc + >> + , ci::opt::compare< item_cmp > + , ci::opt::disposer< mock_disposer > + >::type + > bucket_type; + + typedef ci::MichaelHashSet< rcu_type, bucket_type, + typename ci::michael_set::make_traits< + ci::opt::hash< hash_int > + >::type + > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, member_less ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::template less item_less; + typedef typename TestFixture::hash_int hash_int; + + typedef ci::LazyList< rcu_type + , member_item_type + , typename ci::lazy_list::make_traits< + ci::opt::hook< ci::lazy_list::member_hook< + offsetof( member_item_type, hMember ), + ci::opt::gc + > > + , ci::opt::less< item_less > + , ci::opt::disposer< mock_disposer > + >::type + > bucket_type; + + typedef ci::MichaelHashSet< rcu_type, bucket_type, + typename ci::michael_set::make_traits< + ci::opt::hash< hash_int > + >::type + > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, member_cmpmix ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::hash_int hash_int; + + struct list_traits : public ci::lazy_list::traits + { + typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc> hook; + typedef typename TestFixture::template less less; + typedef typename TestFixture::template cmp compare; + typedef mock_disposer disposer; + }; + typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type; + + struct set_traits : public ci::michael_set::traits + { + typedef hash_int hash; + typedef typename TestFixture::simple_item_counter item_counter; + }; + typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, member_mutex ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_mutex_item_type member_mutex_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::hash_int hash_int; + + struct list_traits : public ci::lazy_list::traits + { + typedef ci::lazy_list::member_hook< offsetof( member_mutex_item_type, hMember ), ci::opt::gc, ci::opt::lock_type> hook; + typedef typename TestFixture::template less less; + typedef typename TestFixture::template cmp compare; + typedef mock_disposer disposer; + }; + typedef ci::LazyList< rcu_type, member_mutex_item_type, list_traits > bucket_type; + + struct set_traits : public ci::michael_set::traits + { + typedef hash_int hash; + typedef typename TestFixture::simple_item_counter item_counter; + }; + typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, member_stat ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::hash_int hash_int; + + struct list_traits: public ci::lazy_list::traits + { + typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc> hook; + typedef typename TestFixture::template cmp compare; + typedef mock_disposer disposer; + typedef ci::lazy_list::stat<> stat; + }; + typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type; + + struct set_traits: public ci::michael_set::traits + { + typedef hash_int hash; + typedef typename TestFixture::simple_item_counter item_counter; + }; + typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); + EXPECT_GE( s.statistics().m_nInsertSuccess, 0u ); +} + +TYPED_TEST_P( IntrusiveMichaelLazySet, member_wrapped_stat ) +{ + typedef typename TestFixture::rcu_type rcu_type; + typedef typename TestFixture::member_item_type member_item_type; + typedef typename TestFixture::mock_disposer mock_disposer; + typedef typename TestFixture::hash_int hash_int; + + struct list_traits: public ci::lazy_list::traits + { + typedef ci::lazy_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc> hook; + typedef typename TestFixture::template cmp compare; + typedef mock_disposer disposer; + typedef ci::lazy_list::wrapped_stat<> stat; + }; + typedef ci::LazyList< rcu_type, member_item_type, list_traits > bucket_type; + + struct set_traits: public ci::michael_set::traits + { + typedef hash_int hash; + typedef typename TestFixture::simple_item_counter item_counter; + }; + typedef ci::MichaelHashSet< rcu_type, bucket_type, set_traits > set_type; + + set_type s( TestFixture::kSize, 2 ); + this->test( s ); + EXPECT_GE( s.statistics().m_nInsertSuccess, 0u ); +} + +// GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as +// "No test named can be found in this test case" +REGISTER_TYPED_TEST_CASE_P( IntrusiveMichaelLazySet, + base_cmp, base_less, base_cmpmix, base_mutex, base_stat, base_wrapped_stat, member_cmp, member_less, member_cmpmix, member_mutex, member_stat, member_wrapped_stat +); + + +#endif // CDSUNIT_SET_TEST_INTRUSIVE_MICHAEL_LAZY_RCU_H +