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_hp.h>
36 namespace ci = cds::intrusive;
37 typedef cds::gc::HP gc_type;
39 class IntrusiveSkipListSet_HP : 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 // +1 - for guarded_ptr
59 cds::gc::hp::GarbageCollector::Construct( set_type::c_nHazardPtrCount + 1, 1, 16 );
60 cds::threading::Manager::attachThread();
65 cds::threading::Manager::detachThread();
66 cds::gc::hp::GarbageCollector::Destruct( true );
71 TEST_F( IntrusiveSkipListSet_HP, base_cmp )
73 struct traits : public ci::skip_list::traits
75 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
76 typedef mock_disposer disposer;
77 typedef cmp<base_item_type> compare;
80 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
86 TEST_F( IntrusiveSkipListSet_HP, base_less )
88 struct traits : public ci::skip_list::traits
90 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
91 typedef mock_disposer disposer;
92 typedef base_class::less<base_item_type> less;
93 typedef cds::atomicity::item_counter item_counter;
96 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
102 TEST_F( IntrusiveSkipListSet_HP, base_cmpmix )
104 struct traits : public ci::skip_list::traits
106 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
107 typedef mock_disposer disposer;
108 typedef cmp<base_item_type> compare;
109 typedef base_class::less<base_item_type> less;
110 typedef ci::skip_list::stat<> stat;
113 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
119 TEST_F( IntrusiveSkipListSet_HP, base_xorshift )
121 struct traits : public ci::skip_list::traits
123 typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
124 typedef mock_disposer disposer;
125 typedef cmp<base_item_type> compare;
126 typedef ci::skip_list::xorshift random_level_generator;
129 typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
136 TEST_F( IntrusiveSkipListSet_HP, member_cmp )
138 struct traits : public ci::skip_list::traits
140 typedef ci::skip_list::member_hook< offsetof(member_item_type, hMember), ci::opt::gc< gc_type >> hook;
141 typedef mock_disposer disposer;
142 typedef cmp<member_item_type> compare;
145 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
151 TEST_F( IntrusiveSkipListSet_HP, member_less )
153 struct traits : public ci::skip_list::traits
155 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
156 typedef mock_disposer disposer;
157 typedef base_class::less<member_item_type> less;
158 typedef cds::atomicity::item_counter item_counter;
159 typedef ci::opt::v::sequential_consistent memory_model;
162 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
168 TEST_F( IntrusiveSkipListSet_HP, member_cmpmix )
170 struct traits : public ci::skip_list::traits
172 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
173 typedef mock_disposer disposer;
174 typedef cmp<member_item_type> compare;
175 typedef base_class::less<member_item_type> less;
176 typedef ci::skip_list::stat<> stat;
179 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
185 TEST_F( IntrusiveSkipListSet_HP, member_xorshift )
187 struct traits : public ci::skip_list::traits
189 typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
190 typedef mock_disposer disposer;
191 typedef cmp<member_item_type> compare;
192 typedef ci::skip_list::xorshift random_level_generator;
195 typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;