--- /dev/null
+/*
+ This file is a part of libcds - Concurrent Data Structures library
+
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+ 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.
+*/
+\r
+#include "test_intrusive_treiber_stack.h"\r
+\r
+#include <cds/gc/dhp.h>\r
+#include <cds/intrusive/treiber_stack.h>\r
+\r
+namespace {\r
+\r
+ namespace ci = cds::intrusive;\r
+\r
+ class IntrusiveTreiberStack_DHP : public cds_gtest::IntrusiveTreiberStack\r
+ {\r
+ typedef cds_gtest::IntrusiveTreiberStack base_class;\r
+ protected:\r
+ typedef cds::gc::DHP gc_type;\r
+\r
+ void SetUp()\r
+ {\r
+ typedef cds::intrusive::TreiberStack< gc_type,
+ base_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ ci::opt::hook<
+ ci::treiber_stack::base_hook<
+ ci::opt::gc<gc_type>
+ >
+ >
+ >::type
+ > stack_type;
+\r
+ cds::gc::dhp::GarbageCollector::Construct( 16, stack_type::c_nHazardPtrCount );\r
+ cds::threading::Manager::attachThread();\r
+ }\r
+\r
+ void TearDown()\r
+ {\r
+ cds::threading::Manager::detachThread();\r
+ cds::gc::dhp::GarbageCollector::Destruct();\r
+ }\r
+\r
+ template <typename Stack>\r
+ void test()\r
+ {\r
+ Stack stack;\r
+ base_class::test( stack );\r
+ }\r
+\r
+ template <typename Stack>\r
+ void test_dyn( size_t elimination_size )\r
+ {\r
+ Stack stack( elimination_size );\r
+ base_class::test( stack );\r
+ }\r
+ };\r
+\r
+ TEST_F( IntrusiveTreiberStack_DHP, base )
+ {
+ typedef cds::intrusive::TreiberStack< gc_type,
+ base_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ ci::opt::hook<
+ ci::treiber_stack::base_hook<
+ ci::opt::gc<gc_type>
+ >
+ >
+ >::type
+ > stack_type;
+
+ test<stack_type>();
+ }
+
+ TEST_F( IntrusiveTreiberStack_DHP, base_disposer )
+ {
+ struct traits:
+ ci::treiber_stack::make_traits <
+ ci::opt::hook<
+ ci::treiber_stack::base_hook< ci::opt::gc<gc_type>>
+ >
+ ,ci::opt::disposer< mock_disposer >
+ >::type
+ {};
+ typedef cds::intrusive::TreiberStack<
+ gc_type,
+ base_hook_item<gc_type>,
+ traits
+ > stack_type;
+
+ test<stack_type>();
+ }
+
+ TEST_F( IntrusiveTreiberStack_DHP, member )
+ {
+ struct traits
+ : ci::treiber_stack::make_traits <
+ ci::opt::hook<
+ ci::treiber_stack::member_hook<
+ offsetof( member_hook_item<gc_type>, hMember),
+ ci::opt::gc<gc_type>
+ >
+ >
+ > ::type
+ {};
+ typedef cds::intrusive::TreiberStack<
+ gc_type,
+ member_hook_item<gc_type>,
+ traits
+ > stack_type;
+
+ test<stack_type>();
+ }
+
+ TEST_F( IntrusiveTreiberStack_DHP, member_disposer )
+ {
+ struct traits
+ : ci::treiber_stack::make_traits <
+ ci::opt::hook<
+ ci::treiber_stack::member_hook<
+ offsetof( member_hook_item<gc_type>, hMember),
+ ci::opt::gc<gc_type>
+ >
+ >
+ ,ci::opt::disposer< mock_disposer >
+ >::type
+ {};
+ typedef cds::intrusive::TreiberStack<
+ gc_type,
+ member_hook_item<gc_type>,
+ traits
+ > stack_type;
+
+ test<stack_type>();
+ }
+
+ TEST_F( IntrusiveTreiberStack_DHP, relaxed )
+ {
+ typedef cds::intrusive::TreiberStack< gc_type,
+ base_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ ci::opt::memory_model< ci::opt::v::relaxed_ordering >
+ ,ci::opt::hook<
+ ci::treiber_stack::base_hook<
+ ci::opt::gc<gc_type>
+ >
+ >
+ >::type
+ > stack_type;
+
+ test<stack_type>();
+ }
+\r
+ TEST_F( IntrusiveTreiberStack_DHP, elimination_base )
+ {
+ typedef cds::intrusive::TreiberStack< gc_type,
+ base_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ cds::opt::enable_elimination<true>
+ ,ci::opt::hook<
+ ci::treiber_stack::base_hook<
+ ci::opt::gc<gc_type>
+ >
+ >
+ >::type
+ > stack_type;
+
+ test<stack_type>();
+ }
+\r
+ TEST_F( IntrusiveTreiberStack_DHP, elimination_base_dynamic )
+ {
+ typedef cds::intrusive::TreiberStack< gc_type,
+ base_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ cds::opt::enable_elimination<true>
+ ,ci::opt::hook<
+ ci::treiber_stack::base_hook<
+ ci::opt::gc<gc_type>
+ >
+ >
+ ,ci::opt::buffer< ci::opt::v::dynamic_buffer<void *> >
+ >::type
+ > stack_type;
+
+ test_dyn<stack_type>( 2 );
+ }
+\r
+ TEST_F( IntrusiveTreiberStack_DHP, elimination_base_disposer )
+ {
+ typedef cds::intrusive::TreiberStack< gc_type,
+ base_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ cds::opt::enable_elimination<true>
+ ,ci::opt::hook<
+ ci::treiber_stack::base_hook< ci::opt::gc<gc_type> >
+ >
+ ,ci::opt::disposer< mock_disposer >
+ >::type
+ > stack_type;
+
+ test<stack_type>();
+ }
+\r
+ TEST_F( IntrusiveTreiberStack_DHP, elimination_member )
+ {
+ typedef cds::intrusive::TreiberStack< gc_type,
+ member_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ cds::opt::enable_elimination<true>
+ ,ci::opt::hook<
+ ci::treiber_stack::member_hook<
+ offsetof( member_hook_item<gc_type>, hMember),
+ ci::opt::gc<gc_type>
+ >
+ >
+ >::type
+ > stack_type;
+
+ test<stack_type>();
+ }
+\r
+ TEST_F( IntrusiveTreiberStack_DHP, elimination_member_dynamic )
+ {
+ typedef cds::intrusive::TreiberStack< gc_type,
+ member_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ cds::opt::enable_elimination<true>
+ ,ci::opt::hook<
+ ci::treiber_stack::member_hook<
+ offsetof( member_hook_item<gc_type>, hMember),
+ ci::opt::gc<gc_type>
+ >
+ >
+ ,ci::opt::buffer< ci::opt::v::dynamic_buffer<void *> >
+ >::type
+ > stack_type;
+
+ test_dyn<stack_type>( 2 );
+ }
+\r
+ TEST_F( IntrusiveTreiberStack_DHP, elimination_member_disposer )
+ {
+ typedef cds::intrusive::TreiberStack< gc_type,
+ member_hook_item<gc_type>
+ , typename ci::treiber_stack::make_traits<
+ cds::opt::enable_elimination<true>
+ ,ci::opt::hook<
+ ci::treiber_stack::member_hook<
+ offsetof( member_hook_item<gc_type>, hMember),
+ ci::opt::gc<gc_type>
+ >
+ >
+ ,ci::opt::buffer< ci::opt::v::dynamic_buffer<void *> >
+ , ci::opt::disposer< mock_disposer >
+ >::type
+ > stack_type;
+
+ test_dyn<stack_type>( 2 );
+ }
+\r
+} // namespace\r
+\r