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_tree_map_hp.h"
33 #include <cds/container/ellen_bintree_map_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 EllenBinTreeMap_HP : public cds_test::container_tree_map_hp
43 typedef cds_test::container_tree_map_hp base_class;
47 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type > map_type;
49 // +1 - for guarded_ptr
50 cds::gc::hp::GarbageCollector::Construct( map_type::c_nHazardPtrCount + 1, 1, 16 );
51 cds::threading::Manager::attachThread();
56 cds::threading::Manager::detachThread();
57 cds::gc::hp::GarbageCollector::Destruct( true );
62 TEST_F( EllenBinTreeMap_HP, compare )
64 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type,
65 typename cc::ellen_bintree::make_map_traits<
66 cds::opt::compare< cmp >
74 TEST_F( EllenBinTreeMap_HP, less )
76 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type,
77 typename cc::ellen_bintree::make_map_traits<
78 cds::opt::less< base_class::less >
86 TEST_F( EllenBinTreeMap_HP, cmpmix )
88 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type,
89 typename cc::ellen_bintree::make_map_traits<
90 cds::opt::less< base_class::less >
91 ,cds::opt::compare< cmp >
99 TEST_F( EllenBinTreeMap_HP, update_desc_pool )
101 struct map_traits: public cc::ellen_bintree::traits
104 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
106 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
112 TEST_F( EllenBinTreeMap_HP, update_desc_lazy_pool )
114 struct map_traits: public cc::ellen_bintree::traits
117 typedef cds::memory::pool_allocator< cds_test::update_desc, cds_test::lazy_pool_accessor> update_desc_allocator;
119 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
125 TEST_F( EllenBinTreeMap_HP, item_counting )
127 struct map_traits: public cc::ellen_bintree::traits
130 typedef base_class::less less;
131 typedef cds::atomicity::item_counter item_counter;
132 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
134 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
140 TEST_F( EllenBinTreeMap_HP, backoff )
142 struct map_traits: public cc::ellen_bintree::traits
145 typedef base_class::less less;
146 typedef cds::atomicity::item_counter item_counter;
147 typedef cds::backoff::yield back_off;
148 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::lazy_pool_accessor> update_desc_allocator;
150 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
156 TEST_F( EllenBinTreeMap_HP, stat )
158 struct map_traits: public cc::ellen_bintree::traits
160 typedef base_class::less less;
161 typedef cds::atomicity::item_counter item_counter;
162 typedef cds::backoff::yield back_off;
163 typedef cc::ellen_bintree::stat<> stat;
164 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
166 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
172 TEST_F( EllenBinTreeMap_HP, copy_policy )
174 struct map_traits: public cc::ellen_bintree::traits
176 typedef base_class::less less;
177 typedef cds::atomicity::item_counter item_counter;
178 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
179 typedef copy_key copy_policy;
181 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
187 TEST_F( EllenBinTreeMap_HP, seq_cst )
189 struct map_traits: public cc::ellen_bintree::traits
192 typedef cds::atomicity::item_counter item_counter;
193 typedef cds::backoff::yield back_off;
194 typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::lazy_pool_accessor> update_desc_allocator;
195 typedef cds::opt::v::sequential_consistent memory_model;
197 typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;