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_kv_list_hp.h"
32 #include <cds/container/lazy_kvlist_hp.h>
35 namespace cc = cds::container;
36 typedef cds::gc::HP gc_type;
38 class LazyKVList_HP : public cds_test::kv_list_hp
43 typedef cc::LazyKVList< gc_type, key_type, value_type > list_type;
45 // +1 - for guarded_ptr
46 cds::gc::hp::GarbageCollector::Construct( list_type::c_nHazardPtrCount + 1, 1, 16 );
47 cds::threading::Manager::attachThread();
52 cds::threading::Manager::detachThread();
53 cds::gc::hp::GarbageCollector::Destruct( true );
57 TEST_F( LazyKVList_HP, less_ordered )
59 typedef cc::LazyKVList< gc_type, key_type, value_type,
60 typename cc::lazy_list::make_traits<
67 test_ordered_iterator( l );
71 TEST_F( LazyKVList_HP, compare_ordered )
73 typedef cc::LazyKVList< gc_type, key_type, value_type,
74 typename cc::lazy_list::make_traits<
75 cds::opt::compare< cmp >
81 test_ordered_iterator( l );
85 TEST_F( LazyKVList_HP, mix_ordered )
87 typedef cc::LazyKVList< gc_type, key_type, value_type,
88 typename cc::lazy_list::make_traits<
89 cds::opt::compare< cmp >
96 test_ordered_iterator( l );
100 TEST_F( LazyKVList_HP, item_counting )
102 struct traits : public cc::lazy_list::traits
105 typedef cds::atomicity::item_counter item_counter;
107 typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
111 test_ordered_iterator( l );
115 TEST_F( LazyKVList_HP, backoff )
117 struct traits : public cc::lazy_list::traits
120 typedef cds::atomicity::item_counter item_counter;
121 typedef cds::backoff::empty back_off;
123 typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
127 test_ordered_iterator( l );
131 TEST_F( LazyKVList_HP, seq_cst )
133 struct traits : public cc::lazy_list::traits
136 typedef cds::atomicity::item_counter item_counter;
137 typedef cds::opt::v::sequential_consistent memory_model;
139 typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
143 test_ordered_iterator( l );
147 TEST_F( LazyKVList_HP, mutex )
149 struct traits : public cc::lazy_list::traits
152 typedef cds::atomicity::item_counter item_counter;
153 typedef std::mutex lock_type;
155 typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
159 test_ordered_iterator( l );
163 TEST_F( LazyKVList_HP, stat )
165 struct traits: public cc::lazy_list::traits
168 typedef cds::atomicity::item_counter item_counter;
169 typedef cds::container::lazy_list::stat<> stat;
171 typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
175 test_ordered_iterator( l );
179 TEST_F( LazyKVList_HP, wrapped_stat )
181 struct traits: public cc::lazy_list::traits
184 typedef cds::atomicity::item_counter item_counter;
185 typedef cds::container::lazy_list::wrapped_stat<> stat;
187 typedef cc::LazyKVList<gc_type, key_type, value_type, traits > list_type;
189 cds::container::lazy_list::stat<> st;
192 test_ordered_iterator( l );