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_tree_set_hp.h"
33 #include <cds/container/ellen_bintree_set_hp.h>
34 #include "test_ellen_bintree_update_desc_pool.h"
37 namespace cc = cds::container;
38 typedef cds::gc::HP gc_type;
40 class EllenBinTreeSet_HP : public cds_test::container_tree_set_hp
43 typedef cds_test::container_tree_set_hp base_class;
46 struct generic_traits: public cc::ellen_bintree::traits
48 typedef base_class::key_extractor key_extractor;
53 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item > set_type;
55 // +1 - for guarded_ptr
56 cds::gc::hp::GarbageCollector::Construct( set_type::c_nHazardPtrCount + 1, 1, 16 );
57 cds::threading::Manager::attachThread();
62 cds::threading::Manager::detachThread();
63 cds::gc::hp::GarbageCollector::Destruct( true );
68 TEST_F( EllenBinTreeSet_HP, compare )
70 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item,
71 typename cc::ellen_bintree::make_set_traits<
72 cc::opt::type_traits< generic_traits >
73 ,cds::opt::compare< cmp >
81 TEST_F( EllenBinTreeSet_HP, less )
83 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item,
84 typename cc::ellen_bintree::make_set_traits<
85 cc::opt::type_traits< generic_traits >
86 ,cds::opt::less< base_class::less >
94 TEST_F( EllenBinTreeSet_HP, cmpmix )
96 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item,
97 typename cc::ellen_bintree::make_set_traits<
98 cc::opt::type_traits< generic_traits >
99 ,cds::opt::less< base_class::less >
100 ,cds::opt::compare< cmp >
108 TEST_F( EllenBinTreeSet_HP, update_desc_pool )
110 struct set_traits: public generic_traits
113 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
115 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item, set_traits > set_type;
121 TEST_F( EllenBinTreeSet_HP, update_desc_lazy_pool )
123 struct set_traits: public generic_traits
126 typedef cds::memory::pool_allocator< cds_test::update_desc, cds_test::lazy_pool_accessor> update_desc_allocator;
128 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item, set_traits > set_type;
134 TEST_F( EllenBinTreeSet_HP, item_counting )
136 struct set_traits: public generic_traits
139 typedef base_class::less less;
140 typedef cds::atomicity::item_counter item_counter;
141 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
143 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item, set_traits > set_type;
149 TEST_F( EllenBinTreeSet_HP, backoff )
151 struct set_traits: public generic_traits
154 typedef base_class::less less;
155 typedef cds::atomicity::item_counter item_counter;
156 typedef cds::backoff::yield back_off;
157 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::lazy_pool_accessor> update_desc_allocator;
159 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item, set_traits > set_type;
165 TEST_F( EllenBinTreeSet_HP, stat )
167 struct set_traits: public generic_traits
169 typedef base_class::less less;
170 typedef cds::atomicity::item_counter item_counter;
171 typedef cds::backoff::yield back_off;
172 typedef cc::ellen_bintree::stat<> stat;
173 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
175 typedef cc::EllenBinTreeSet< gc_type, key_type, int_item, set_traits > set_type;