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_intrusive_michael_iterable_hp.h"
33 #include <cds/intrusive/iterable_list_hp.h>
34 #include <cds/intrusive/michael_set.h>
37 namespace ci = cds::intrusive;
38 typedef cds::gc::HP gc_type;
40 class IntrusiveMichaelIterableSet_HP : public cds_test::intrusive_set_hp
43 typedef cds_test::intrusive_set_hp base_class;
48 struct list_traits : public ci::iterable_list::traits
50 typedef ci::IterableList< gc_type, item_type, list_traits > list_type;
51 typedef ci::MichaelHashSet< gc_type, list_type > set_type;
54 cds::gc::hp::GarbageCollector::Construct( set_type::c_nHazardPtrCount + 3, 1, 16 );
55 cds::threading::Manager::attachThread();
60 cds::threading::Manager::detachThread();
61 cds::gc::hp::GarbageCollector::Destruct( true );
66 TEST_F( IntrusiveMichaelIterableSet_HP, cmp )
68 typedef ci::IterableList< gc_type
70 ,ci::iterable_list::make_traits<
71 ci::opt::compare< cmp<item_type> >
72 ,ci::opt::disposer< mock_disposer >
76 typedef ci::MichaelHashSet< gc_type, bucket_type,
77 ci::michael_set::make_traits<
78 ci::opt::hash< hash_int >
82 set_type s( kSize, 2 );
86 TEST_F( IntrusiveMichaelIterableSet_HP, less )
88 typedef ci::IterableList< gc_type
90 ,ci::iterable_list::make_traits<
91 ci::opt::less< less<item_type> >
92 ,ci::opt::disposer< mock_disposer >
96 typedef ci::MichaelHashSet< gc_type, bucket_type,
97 ci::michael_set::make_traits<
98 ci::opt::hash< hash_int >
102 set_type s( kSize, 2 );
106 TEST_F( IntrusiveMichaelIterableSet_HP, cmpmix )
108 struct list_traits : public ci::iterable_list::traits
110 typedef base_class::less<item_type> less;
111 typedef cmp<item_type> compare;
112 typedef mock_disposer disposer;
114 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
116 struct set_traits : public ci::michael_set::traits
118 typedef hash_int hash;
119 typedef simple_item_counter item_counter;
121 typedef ci::MichaelHashSet< gc_type, bucket_type, set_traits > set_type;
123 set_type s( kSize, 2 );
127 TEST_F( IntrusiveMichaelIterableSet_HP, stat )
129 struct list_traits: public ci::iterable_list::traits
131 typedef base_class::less<item_type> less;
132 typedef cmp<item_type> compare;
133 typedef mock_disposer disposer;
134 typedef ci::iterable_list::stat<> stat;
136 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
138 struct set_traits: public ci::michael_set::traits
140 typedef hash_int hash;
141 typedef simple_item_counter item_counter;
143 typedef ci::MichaelHashSet< gc_type, bucket_type, set_traits > set_type;
145 set_type s( kSize, 2 );
147 EXPECT_GE( s.statistics().m_nInsertSuccess, 0u );
150 TEST_F( IntrusiveMichaelIterableSet_HP, wrapped_stat )
152 struct list_traits: public ci::iterable_list::traits
154 typedef base_class::less<item_type> less;
155 typedef cmp<item_type> compare;
156 typedef mock_disposer disposer;
157 typedef ci::iterable_list::wrapped_stat<> stat;
159 typedef ci::IterableList< gc_type, item_type, list_traits > bucket_type;
161 struct set_traits: public ci::michael_set::traits
163 typedef hash_int hash;
164 typedef simple_item_counter item_counter;
166 typedef ci::MichaelHashSet< gc_type, bucket_type, set_traits > set_type;
168 set_type s( kSize, 2 );
170 EXPECT_GE( s.statistics().m_nInsertSuccess, 0u );