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_split_iterable_set_hp.h"
33 #include <cds/intrusive/iterable_list_dhp.h>
34 #include <cds/intrusive/split_list.h>
35 #include <cds/intrusive/free_list.h>
38 namespace ci = cds::intrusive;
39 typedef cds::gc::DHP gc_type;
41 class IntrusiveSplitListIterableSet_DHP : public cds_test::intrusive_split_iterable_set_hp
44 typedef cds_test::intrusive_split_iterable_set_hp base_class;
45 typedef base_class::item_type< ci::split_list::node<void>> item_type;
50 struct list_traits : public ci::iterable_list::traits
52 typedef ci::IterableList< gc_type, item_type, list_traits > list_type;
53 typedef ci::SplitListSet< gc_type, list_type > set_type;
55 cds::gc::dhp::GarbageCollector::Construct( 16, set_type::c_nHazardPtrCount );
56 cds::threading::Manager::attachThread();
61 cds::threading::Manager::detachThread();
62 cds::gc::hp::GarbageCollector::Destruct();
67 TEST_F( IntrusiveSplitListIterableSet_DHP, cmp )
69 typedef ci::IterableList< gc_type
71 ,ci::iterable_list::make_traits<
72 ci::opt::compare< cmp<item_type> >
73 ,ci::opt::disposer< mock_disposer >
77 typedef ci::SplitListSet< gc_type, bucket_type,
78 ci::split_list::make_traits<
79 ci::opt::hash< hash_int >
83 set_type s( kSize, 2 );
87 TEST_F( IntrusiveSplitListIterableSet_DHP, less )
89 typedef ci::IterableList< gc_type
91 ,ci::iterable_list::make_traits<
92 ci::opt::less< less<item_type> >
93 ,ci::opt::disposer< mock_disposer >
97 typedef ci::SplitListSet< gc_type, bucket_type,
98 ci::split_list::make_traits<
99 ci::opt::hash< hash_int >
103 set_type s( kSize, 2 );
107 TEST_F( IntrusiveSplitListIterableSet_DHP, cmpmix )
109 struct list_traits : public ci::iterable_list::traits
111 typedef base_class::less<item_type> less;
112 typedef cmp<item_type> compare;
113 typedef mock_disposer disposer;
115 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
117 struct set_traits : public ci::split_list::traits
119 typedef hash_int hash;
120 typedef simple_item_counter item_counter;
122 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
124 set_type s( kSize, 2 );
128 TEST_F( IntrusiveSplitListIterableSet_DHP, free_list )
130 struct list_traits: public ci::iterable_list::traits
132 typedef base_class::less<item_type> less;
133 typedef cmp<item_type> compare;
134 typedef mock_disposer disposer;
136 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
138 struct set_traits: public ci::split_list::traits
140 typedef hash_int hash;
141 typedef ci::FreeList free_list;
143 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
145 set_type s( kSize, 2 );
149 TEST_F( IntrusiveSplitListIterableSet_DHP, static_bucket_table )
151 struct list_traits: public ci::iterable_list::traits
153 typedef base_class::less<item_type> less;
154 typedef cmp<item_type> compare;
155 typedef mock_disposer disposer;
157 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
159 struct set_traits: public ci::split_list::traits
161 typedef hash_int hash;
163 dynamic_bucket_table = false
166 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
168 set_type s( kSize, 2 );
172 TEST_F( IntrusiveSplitListIterableSet_DHP, static_bucket_table_free_list )
174 struct list_traits: public ci::iterable_list::traits
176 typedef base_class::less<item_type> less;
177 typedef cmp<item_type> compare;
178 typedef mock_disposer disposer;
180 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
182 struct set_traits: public ci::split_list::traits
184 typedef hash_int hash;
186 dynamic_bucket_table = false
188 typedef ci::FreeList free_list;
190 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
192 set_type s( kSize, 2 );
196 TEST_F( IntrusiveSplitListIterableSet_DHP, list_stat )
198 struct list_traits: public ci::iterable_list::traits
200 typedef base_class::less<item_type> less;
201 typedef cmp<item_type> compare;
202 typedef mock_disposer disposer;
203 typedef ci::iterable_list::stat<> stat;
205 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
207 struct set_traits: public ci::split_list::traits
209 typedef hash_int hash;
210 typedef simple_item_counter item_counter;
212 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
214 set_type s( kSize, 2 );
216 EXPECT_GE( s.list_statistics().m_nInsertSuccess, 0u );
219 TEST_F( IntrusiveSplitListIterableSet_DHP, stat )
221 struct list_traits: public ci::iterable_list::traits
223 typedef base_class::less<item_type> less;
224 typedef cmp<item_type> compare;
225 typedef mock_disposer disposer;
227 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
229 struct set_traits: public ci::split_list::traits
231 typedef hash_int hash;
232 typedef simple_item_counter item_counter;
233 typedef ci::split_list::stat<> stat;
235 typedef ci::SplitListSet< gc_type, bucket_type, set_traits > set_type;
237 set_type s( kSize, 2 );
239 EXPECT_GE( s.statistics().m_nInsertSuccess, 0u );