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_feldman_hashset_hp.h"
33 #include <cds/container/feldman_hashset_hp.h>
36 namespace cc = cds::container;
37 typedef cds::gc::HP gc_type;
39 class FeldmanHashSet_HP : public cds_test::feldman_hashset_hp
42 typedef cds_test::feldman_hashset_hp base_class;
46 struct set_traits: public cc::feldman_hashset::traits
48 typedef get_hash hash_accessor;
50 typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
52 // +1 - for guarded_ptr
53 cds::gc::hp::GarbageCollector::Construct( set_type::c_nHazardPtrCount + 1, 1, 16 );
54 cds::threading::Manager::attachThread();
59 cds::threading::Manager::detachThread();
60 cds::gc::hp::GarbageCollector::Destruct( true );
64 TEST_F( FeldmanHashSet_HP, defaulted )
66 typedef cc::FeldmanHashSet< gc_type, int_item,
67 typename cc::feldman_hashset::make_traits<
68 cc::feldman_hashset::hash_accessor< get_hash >
76 TEST_F( FeldmanHashSet_HP, compare )
78 typedef cc::FeldmanHashSet< gc_type, int_item,
79 typename cc::feldman_hashset::make_traits<
80 cc::feldman_hashset::hash_accessor< get_hash >
81 ,cds::opt::compare< cmp >
89 TEST_F( FeldmanHashSet_HP, less )
91 typedef cc::FeldmanHashSet< gc_type, int_item,
92 typename cc::feldman_hashset::make_traits<
93 cc::feldman_hashset::hash_accessor< get_hash >
94 ,cds::opt::less< std::less<int> >
102 TEST_F( FeldmanHashSet_HP, cmpmix )
104 typedef cc::FeldmanHashSet< gc_type, int_item,
105 typename cc::feldman_hashset::make_traits<
106 cc::feldman_hashset::hash_accessor< get_hash >
107 , cds::opt::less< std::less<int> >
108 ,cds::opt::compare< cmp >
116 TEST_F( FeldmanHashSet_HP, item_counting )
118 struct set_traits: public cc::feldman_hashset::traits
120 typedef get_hash hash_accessor;
122 typedef std::less<int> less;
123 typedef simple_item_counter item_counter;
125 typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
131 TEST_F( FeldmanHashSet_HP, backoff )
133 struct set_traits: public cc::feldman_hashset::traits
135 typedef get_hash hash_accessor;
137 typedef cds::atomicity::item_counter item_counter;
138 typedef cds::backoff::yield back_off;
140 typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
146 TEST_F( FeldmanHashSet_HP, stat )
148 struct set_traits: public cc::feldman_hashset::traits
150 typedef get_hash hash_accessor;
151 typedef cds::backoff::yield back_off;
152 typedef cc::feldman_hashset::stat<> stat;
154 typedef cc::FeldmanHashSet< gc_type, int_item, set_traits > set_type;
160 TEST_F( FeldmanHashSet_HP, explicit_hash_size )
162 struct set_traits: public cc::feldman_hashset::traits
164 typedef get_hash2 hash_accessor;
166 hash_size = sizeof( std::declval<key_val>(). nKey )
168 typedef cmp2 compare;
169 typedef cc::feldman_hashset::stat<> stat;
171 typedef cc::FeldmanHashSet< gc_type, int_item2, set_traits > set_type;