2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "test_intrusive_michael_iterable_hp.h"
33 #include <cds/intrusive/iterable_list_dhp.h>
34 #include <cds/intrusive/michael_set.h>
37 namespace ci = cds::intrusive;
38 typedef cds::gc::DHP gc_type;
40 class IntrusiveMichaelIterableSet_DHP : public cds_test::intrusive_set_hp
43 typedef cds_test::intrusive_set_hp base_class;
48 struct list_traits : public ci::iterable_list::traits
50 typedef ci::IterableList< gc_type, item_type, list_traits > list_type;
51 typedef ci::MichaelHashSet< gc_type, list_type > set_type;
53 cds::gc::dhp::GarbageCollector::Construct( 16, set_type::c_nHazardPtrCount );
54 cds::threading::Manager::attachThread();
59 cds::threading::Manager::detachThread();
60 cds::gc::dhp::GarbageCollector::Destruct();
65 TEST_F( IntrusiveMichaelIterableSet_DHP, cmp )
67 typedef ci::IterableList< gc_type
69 ,ci::iterable_list::make_traits<
70 ci::opt::compare< cmp<item_type> >
71 ,ci::opt::disposer< mock_disposer >
75 typedef ci::MichaelHashSet< gc_type, bucket_type,
76 ci::michael_set::make_traits<
77 ci::opt::hash< hash_int >
81 set_type s( kSize, 2 );
85 TEST_F( IntrusiveMichaelIterableSet_DHP, less )
87 typedef ci::IterableList< gc_type
89 ,ci::iterable_list::make_traits<
90 ci::opt::less< less<item_type> >
91 ,ci::opt::disposer< mock_disposer >
95 typedef ci::MichaelHashSet< gc_type, bucket_type,
96 ci::michael_set::make_traits<
97 ci::opt::hash< hash_int >
101 set_type s( kSize, 2 );
105 TEST_F( IntrusiveMichaelIterableSet_DHP, cmpmix )
107 struct list_traits : public ci::iterable_list::traits
109 typedef base_class::less<item_type> less;
110 typedef cmp<item_type> compare;
111 typedef mock_disposer disposer;
113 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
115 struct set_traits : public ci::michael_set::traits
117 typedef hash_int hash;
118 typedef simple_item_counter item_counter;
120 typedef ci::MichaelHashSet< gc_type, bucket_type, set_traits > set_type;
122 set_type s( kSize, 2 );
126 TEST_F( IntrusiveMichaelIterableSet_DHP, stat )
128 struct list_traits: public ci::iterable_list::traits
130 typedef base_class::less<item_type> less;
131 typedef mock_disposer disposer;
132 typedef ci::iterable_list::stat<> stat;
134 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
136 struct set_traits: public ci::michael_set::traits
138 typedef hash_int hash;
139 typedef simple_item_counter item_counter;
141 typedef ci::MichaelHashSet< gc_type, bucket_type, set_traits > set_type;
143 set_type s( kSize, 2 );
145 EXPECT_GE( s.statistics().m_nInsertSuccess, 0u );
148 TEST_F( IntrusiveMichaelIterableSet_DHP, wrapped_stat )
150 struct list_traits: public ci::iterable_list::traits
152 typedef base_class::less<item_type> less;
153 typedef mock_disposer disposer;
154 typedef ci::iterable_list::wrapped_stat<> stat;
156 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
158 struct set_traits: public ci::michael_set::traits
160 typedef hash_int hash;
161 typedef simple_item_counter item_counter;
163 typedef ci::MichaelHashSet< gc_type, bucket_type, set_traits > set_type;
165 set_type s( kSize, 2 );
167 EXPECT_GE( s.statistics().m_nInsertSuccess, 0u );
170 TEST_F( IntrusiveMichaelIterableSet_DHP, derived_list )
172 class bucket_type: public ci::IterableList< gc_type
174 ,ci::iterable_list::make_traits<
175 ci::opt::compare< cmp<item_type> >
176 ,ci::opt::disposer< mock_disposer >
181 typedef ci::MichaelHashSet< gc_type, bucket_type,
182 ci::michael_set::make_traits<
183 ci::opt::hash< hash_int >
187 set_type s( kSize, 2 );