2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
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_set_hp.h"
33 #include <cds/intrusive/skip_list_dhp.h>
36 namespace ci = cds::intrusive;
37 typedef cds::gc::DHP gc_type;
39 class IntrusiveSkipListSet_DHP : public cds_test::intrusive_set_hp
42 typedef cds_test::intrusive_set_hp base_class;
45 typedef typename base_class::base_int_item< ci::skip_list::node< gc_type>> base_item_type;
46 typedef typename base_class::member_int_item< ci::skip_list::node< gc_type>> member_item_type;
50 typedef ci::SkipListSet< gc_type, base_item_type,
51 typename ci::skip_list::make_traits<
52 ci::opt::hook<ci::skip_list::base_hook< ci::opt::gc< gc_type >>>
53 ,ci::opt::disposer<mock_disposer>
54 ,ci::opt::compare<mock_disposer>
58 cds::gc::dhp::GarbageCollector::Construct( 16, set_type::c_nHazardPtrCount );
59 cds::threading::Manager::attachThread();
64 cds::threading::Manager::detachThread();
65 cds::gc::dhp::GarbageCollector::Destruct();
70 TEST_F( IntrusiveSkipListSet_DHP, base_cmp )
72 struct traits : public ci::skip_list::traits
74 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
75 typedef mock_disposer disposer;
76 typedef cmp<base_item_type> compare;
79 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
85 TEST_F( IntrusiveSkipListSet_DHP, base_less )
87 struct traits : public ci::skip_list::traits
89 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
90 typedef mock_disposer disposer;
91 typedef base_class::less<base_item_type> less;
92 typedef cds::atomicity::item_counter item_counter;
95 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
101 TEST_F( IntrusiveSkipListSet_DHP, base_cmpmix )
103 struct traits : public ci::skip_list::traits
105 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
106 typedef mock_disposer disposer;
107 typedef cmp<base_item_type> compare;
108 typedef base_class::less<base_item_type> less;
109 typedef ci::skip_list::stat<> stat;
112 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
118 TEST_F( IntrusiveSkipListSet_DHP, base_xorshift )
120 struct traits : public ci::skip_list::traits
122 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
123 typedef mock_disposer disposer;
124 typedef cmp<base_item_type> compare;
125 typedef ci::skip_list::xorshift random_level_generator;
128 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
135 TEST_F( IntrusiveSkipListSet_DHP, member_cmp )
137 struct traits : public ci::skip_list::traits
139 typedef ci::skip_list::member_hook< offsetof(member_item_type, hMember), ci::opt::gc< gc_type >> hook;
140 typedef mock_disposer disposer;
141 typedef cmp<member_item_type> compare;
144 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
150 TEST_F( IntrusiveSkipListSet_DHP, member_less )
152 struct traits : public ci::skip_list::traits
154 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
155 typedef mock_disposer disposer;
156 typedef base_class::less<member_item_type> less;
157 typedef cds::atomicity::item_counter item_counter;
158 typedef ci::opt::v::sequential_consistent memory_model;
161 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
167 TEST_F( IntrusiveSkipListSet_DHP, member_cmpmix )
169 struct traits : public ci::skip_list::traits
171 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
172 typedef mock_disposer disposer;
173 typedef cmp<member_item_type> compare;
174 typedef base_class::less<member_item_type> less;
175 typedef ci::skip_list::stat<> stat;
178 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
184 TEST_F( IntrusiveSkipListSet_DHP, member_xorshift )
186 struct traits : public ci::skip_list::traits
188 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
189 typedef mock_disposer disposer;
190 typedef cmp<member_item_type> compare;
191 typedef ci::skip_list::xorshift random_level_generator;
194 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;