3 #include "set/hdr_striped_set.h"
4 #include <cds/container/striped_set/std_set.h>
5 #include <cds/container/striped_set.h>
6 #include <cds/sync/spinlock.h>
11 struct my_copy_policy {
12 typedef std::set<StripedSetHdrTest::item, StripedSetHdrTest::less<StripedSetHdrTest::item> > set_type;
13 typedef set_type::iterator iterator;
15 void operator()( set_type& set, iterator itWhat )
17 set.insert( std::make_pair(itWhat->key(), itWhat->val()) );
21 typedef std::set<StripedSetHdrTest::item, StripedSetHdrTest::less<StripedSetHdrTest::item> > set_t;
24 void StripedSetHdrTest::Refinable_set()
26 CPPUNIT_MESSAGE( "cmp");
27 typedef cc::StripedSet< set_t
28 , co::hash< hash_int >
29 , co::compare< cmp<item> >
30 ,co::mutex_policy< cc::striped_set::refinable<> >
32 test_striped< set_cmp >();
34 CPPUNIT_MESSAGE( "less");
35 typedef cc::StripedSet< set_t
36 ,co::mutex_policy< cc::striped_set::refinable<> >
37 , co::hash< hash_int >
38 , co::less< less<item> >
40 test_striped< set_less >();
42 CPPUNIT_MESSAGE( "cmpmix");
43 typedef cc::StripedSet< set_t
44 ,co::mutex_policy< cc::striped_set::refinable<> >
45 , co::hash< hash_int >
46 , co::compare< cmp<item> >
47 , co::less< less<item> >
49 test_striped< set_cmpmix >();
51 // Spinlock as lock policy
52 CPPUNIT_MESSAGE( "spinlock");
53 typedef cc::StripedSet< set_t
54 , co::mutex_policy< cc::striped_set::refinable<cds::sync::reentrant_spin> >
55 , co::hash< hash_int >
56 , co::less< less<item> >
58 test_striped< set_spin >();
61 CPPUNIT_MESSAGE( "load_factor_resizing<0>(1024)");
63 typedef cc::StripedSet< set_t
64 ,co::mutex_policy< cc::striped_set::refinable<> >
65 , co::hash< hash_int >
66 , co::less< less<item> >
67 , co::resizing_policy< cc::striped_set::load_factor_resizing<0> >
68 > set_less_resizing_lf;
69 set_less_resizing_lf s(30, cc::striped_set::load_factor_resizing<0>(1024));
73 CPPUNIT_MESSAGE( "load_factor_resizing<256>");
74 typedef cc::StripedSet< set_t
75 ,co::mutex_policy< cc::striped_set::refinable<> >
76 , co::hash< hash_int >
77 , co::less< less<item> >
78 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
79 > set_less_resizing_lf16;
80 test_striped< set_less_resizing_lf16 >();
82 CPPUNIT_MESSAGE( "single_bucket_size_threshold<0>(1024)");
84 typedef cc::StripedSet< set_t
85 ,co::mutex_policy< cc::striped_set::refinable<> >
86 , co::hash< hash_int >
87 , co::less< less<item> >
88 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<0> >
89 > set_less_resizing_sbt;
90 set_less_resizing_sbt s(30, cc::striped_set::single_bucket_size_threshold<0>(1024) );
94 CPPUNIT_MESSAGE( "single_bucket_size_threshold<256>");
95 typedef cc::StripedSet< set_t
96 ,co::mutex_policy< cc::striped_set::refinable<> >
97 , co::hash< hash_int >
98 , co::less< less<item> >
99 , co::resizing_policy< cc::striped_set::single_bucket_size_threshold<256> >
100 > set_less_resizing_sbt16;
101 test_striped< set_less_resizing_sbt16 >();
104 CPPUNIT_MESSAGE( "load_factor_resizing<256>, copy_item");
105 typedef cc::StripedSet< set_t
106 ,co::mutex_policy< cc::striped_set::refinable<> >
107 , co::hash< hash_int >
108 , co::compare< cmp<item> >
109 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
110 , co::copy_policy< cc::striped_set::copy_item >
112 test_striped< set_copy_item >();
114 CPPUNIT_MESSAGE( "load_factor_resizing<256>, swap_item");
115 typedef cc::StripedSet< set_t
116 ,co::mutex_policy< cc::striped_set::refinable<> >
117 , co::hash< hash_int >
118 , co::compare< cmp<item> >
119 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
120 , co::copy_policy< cc::striped_set::swap_item >
122 test_striped< set_swap_item >();
124 CPPUNIT_MESSAGE( "load_factor_resizing<256>, move_item");
125 typedef cc::StripedSet< set_t
126 ,co::mutex_policy< cc::striped_set::refinable<> >
127 , co::hash< hash_int >
128 , co::compare< cmp<item> >
129 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
130 , co::copy_policy< cc::striped_set::move_item >
132 test_striped< set_move_item >();
134 CPPUNIT_MESSAGE( "load_factor_resizing<256>, special copy_item");
135 typedef cc::StripedSet< set_t
136 ,co::mutex_policy< cc::striped_set::refinable<> >
137 , co::hash< hash_int >
138 , co::compare< cmp<item> >
139 , co::resizing_policy< cc::striped_set::load_factor_resizing<256> >
140 , co::copy_policy< my_copy_policy >
141 > set_special_copy_item;
142 test_striped< set_special_copy_item >();