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_set_hp.h"
33 #include <cds/container/lazy_list_dhp.h>
34 #include <cds/container/split_list_set.h>
37 namespace cc = cds::container;
38 typedef cds::gc::DHP gc_type;
40 class SplitListLazySet_DHP : public cds_test::container_set_hp
43 typedef cds_test::container_set_hp base_class;
47 struct set_traits: public cc::split_list::traits {
48 typedef cc::lazy_list_tag ordered_list;
49 typedef hash_int hash;
50 struct ordered_list_traits: public cc::lazy_list::traits
55 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
57 cds::gc::dhp::GarbageCollector::Construct( 16, set_type::c_nHazardPtrCount );
58 cds::threading::Manager::attachThread();
63 cds::threading::Manager::detachThread();
64 cds::gc::dhp::GarbageCollector::Destruct();
68 TEST_F( SplitListLazySet_DHP, compare )
70 typedef cc::SplitListSet< gc_type, int_item,
71 typename cc::split_list::make_traits<
72 cc::split_list::ordered_list< cc::lazy_list_tag >
73 , cds::opt::hash< hash_int >
74 , cc::split_list::ordered_list_traits<
75 typename cc::lazy_list::make_traits<
76 cds::opt::compare< cmp >
82 set_type s( kSize, 2 );
86 TEST_F( SplitListLazySet_DHP, less )
88 typedef cc::SplitListSet< gc_type, int_item,
89 typename cc::split_list::make_traits<
90 cc::split_list::ordered_list< cc::lazy_list_tag >
91 , cds::opt::hash< hash_int >
92 , cc::split_list::ordered_list_traits<
93 typename cc::lazy_list::make_traits<
94 cds::opt::less< less >
100 set_type s( kSize, 1 );
104 TEST_F( SplitListLazySet_DHP, cmpmix )
106 typedef cc::SplitListSet< gc_type, int_item,
107 typename cc::split_list::make_traits<
108 cc::split_list::ordered_list< cc::lazy_list_tag >
109 , cds::opt::hash< hash_int >
110 , cc::split_list::ordered_list_traits<
111 typename cc::lazy_list::make_traits<
112 cds::opt::less< less >
113 , cds::opt::compare< cmp >
119 set_type s( kSize, 2 );
123 TEST_F( SplitListLazySet_DHP, item_counting )
125 struct set_traits: public cc::split_list::traits
127 typedef cc::lazy_list_tag ordered_list;
128 typedef hash_int hash;
129 typedef cds::atomicity::item_counter item_counter;
131 struct ordered_list_traits: public cc::lazy_list::traits
134 typedef base_class::less less;
135 typedef cds::backoff::empty back_off;
138 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
140 set_type s( kSize, 4 );
144 TEST_F( SplitListLazySet_DHP, stat )
146 struct set_traits: public cc::split_list::traits
148 typedef cc::lazy_list_tag ordered_list;
149 typedef hash_int hash;
150 typedef cds::atomicity::item_counter item_counter;
151 typedef cc::split_list::stat<> stat;
153 struct ordered_list_traits: public cc::lazy_list::traits
155 typedef base_class::less less;
156 typedef cds::opt::v::sequential_consistent memory_model;
159 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
161 set_type s( kSize, 2 );
165 TEST_F( SplitListLazySet_DHP, back_off )
167 struct set_traits: public cc::split_list::traits
169 typedef cc::lazy_list_tag ordered_list;
170 typedef hash_int hash;
171 typedef cds::atomicity::item_counter item_counter;
172 typedef cds::backoff::yield back_off;
173 typedef cds::opt::v::sequential_consistent memory_model;
175 struct ordered_list_traits: public cc::lazy_list::traits
178 typedef cds::backoff::empty back_off;
181 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
183 set_type s( kSize, 3 );
187 TEST_F( SplitListLazySet_DHP, mutex )
189 struct set_traits: public cc::split_list::traits
191 typedef cc::lazy_list_tag ordered_list;
192 typedef hash_int hash;
193 typedef cds::atomicity::item_counter item_counter;
194 typedef cds::backoff::yield back_off;
195 typedef cds::opt::v::sequential_consistent memory_model;
197 struct ordered_list_traits: public cc::lazy_list::traits
200 typedef cds::backoff::pause back_off;
201 typedef std::mutex lock_type;
204 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
206 set_type s( kSize, 2 );
210 struct set_static_traits: public cc::split_list::traits
212 static bool const dynamic_bucket_table = false;
215 TEST_F( SplitListLazySet_DHP, static_bucket_table )
217 struct set_traits: public set_static_traits
219 typedef cc::lazy_list_tag ordered_list;
220 typedef hash_int hash;
221 typedef cds::atomicity::item_counter item_counter;
223 struct ordered_list_traits: public cc::lazy_list::traits
226 typedef cds::backoff::pause back_off;
229 typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
231 set_type s( kSize, 4 );