split_michael_nogc.cpp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. // Copyright (c) 2006-2018 Maxim Khizhinsky
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #include "test_set_nogc.h"
  6. #include <cds/container/michael_list_nogc.h>
  7. #include <cds/container/split_list_set_nogc.h>
  8. #include <cds/intrusive/free_list.h>
  9. namespace {
  10. namespace cc = cds::container;
  11. typedef cds::gc::nogc gc_type;
  12. class SplitListMichaelSet_NoGC : public cds_test::container_set_nogc
  13. {
  14. protected:
  15. typedef cds_test::container_set_nogc base_class;
  16. //void SetUp()
  17. //{}
  18. //void TearDown()
  19. //{}
  20. };
  21. TEST_F( SplitListMichaelSet_NoGC, compare )
  22. {
  23. typedef cc::SplitListSet< gc_type, int_item,
  24. typename cc::split_list::make_traits<
  25. cc::split_list::ordered_list< cc::michael_list_tag >
  26. , cds::opt::hash< hash_int >
  27. , cc::split_list::ordered_list_traits<
  28. typename cc::michael_list::make_traits<
  29. cds::opt::compare< cmp >
  30. >::type
  31. >
  32. >::type
  33. > set_type;
  34. set_type s( kSize, 2 );
  35. test( s );
  36. }
  37. TEST_F( SplitListMichaelSet_NoGC, less )
  38. {
  39. typedef cc::SplitListSet< gc_type, int_item,
  40. typename cc::split_list::make_traits<
  41. cc::split_list::ordered_list< cc::michael_list_tag >
  42. , cds::opt::hash< hash_int >
  43. , cc::split_list::ordered_list_traits<
  44. typename cc::michael_list::make_traits<
  45. cds::opt::less< less >
  46. >::type
  47. >
  48. >::type
  49. > set_type;
  50. set_type s( kSize, 2 );
  51. test( s );
  52. }
  53. TEST_F( SplitListMichaelSet_NoGC, cmpmix )
  54. {
  55. typedef cc::SplitListSet< gc_type, int_item,
  56. typename cc::split_list::make_traits<
  57. cc::split_list::ordered_list< cc::michael_list_tag >
  58. , cds::opt::hash< hash_int >
  59. , cc::split_list::ordered_list_traits<
  60. typename cc::michael_list::make_traits<
  61. cds::opt::less< less >
  62. , cds::opt::compare< cmp >
  63. >::type
  64. >
  65. >::type
  66. > set_type;
  67. set_type s( kSize, 3 );
  68. test( s );
  69. }
  70. TEST_F( SplitListMichaelSet_NoGC, item_counting )
  71. {
  72. struct set_traits: public cc::split_list::traits
  73. {
  74. typedef cc::michael_list_tag ordered_list;
  75. typedef hash_int hash;
  76. typedef cds::atomicity::item_counter item_counter;
  77. struct ordered_list_traits: public cc::michael_list::traits
  78. {
  79. typedef cmp compare;
  80. typedef base_class::less less;
  81. typedef cds::backoff::empty back_off;
  82. };
  83. };
  84. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  85. set_type s( kSize, 4 );
  86. test( s );
  87. }
  88. TEST_F( SplitListMichaelSet_NoGC, stat )
  89. {
  90. struct set_traits: public cc::split_list::traits
  91. {
  92. typedef cc::michael_list_tag ordered_list;
  93. typedef hash_int hash;
  94. typedef cds::atomicity::item_counter item_counter;
  95. typedef cc::split_list::stat<> stat;
  96. struct ordered_list_traits: public cc::michael_list::traits
  97. {
  98. typedef base_class::less less;
  99. typedef cds::opt::v::sequential_consistent memory_model;
  100. };
  101. };
  102. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  103. set_type s( kSize, 5 );
  104. test( s );
  105. }
  106. TEST_F( SplitListMichaelSet_NoGC, back_off )
  107. {
  108. struct set_traits: public cc::split_list::traits
  109. {
  110. typedef cc::michael_list_tag ordered_list;
  111. typedef hash_int hash;
  112. typedef cds::atomicity::item_counter item_counter;
  113. typedef cds::backoff::yield back_off;
  114. typedef cds::opt::v::sequential_consistent memory_model;
  115. struct ordered_list_traits: public cc::michael_list::traits
  116. {
  117. typedef cmp compare;
  118. typedef cds::backoff::pause back_off;
  119. };
  120. };
  121. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  122. set_type s( kSize, 2 );
  123. test( s );
  124. }
  125. TEST_F( SplitListMichaelSet_NoGC, free_list )
  126. {
  127. struct set_traits: public cc::split_list::traits
  128. {
  129. typedef cc::michael_list_tag ordered_list;
  130. typedef hash_int hash;
  131. typedef cds::intrusive::FreeList free_list;
  132. struct ordered_list_traits: public cc::michael_list::traits
  133. {
  134. typedef cmp compare;
  135. typedef cds::backoff::pause back_off;
  136. };
  137. };
  138. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  139. set_type s( kSize, 2 );
  140. test( s );
  141. }
  142. struct set_static_traits: public cc::split_list::traits
  143. {
  144. static bool const dynamic_bucket_table = false;
  145. };
  146. TEST_F( SplitListMichaelSet_NoGC, static_bucket_table )
  147. {
  148. struct set_traits: public set_static_traits
  149. {
  150. typedef cc::michael_list_tag ordered_list;
  151. typedef hash_int hash;
  152. typedef cds::atomicity::item_counter item_counter;
  153. struct ordered_list_traits: public cc::michael_list::traits
  154. {
  155. typedef cmp compare;
  156. typedef cds::backoff::pause back_off;
  157. };
  158. };
  159. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  160. set_type s( kSize, 4 );
  161. test( s );
  162. }
  163. TEST_F( SplitListMichaelSet_NoGC, static_bucket_table_free_list )
  164. {
  165. struct set_traits: public set_static_traits
  166. {
  167. typedef cc::michael_list_tag ordered_list;
  168. typedef hash_int hash;
  169. typedef cds::atomicity::item_counter item_counter;
  170. typedef cds::intrusive::FreeList free_list;
  171. struct ordered_list_traits: public cc::michael_list::traits
  172. {
  173. typedef cmp compare;
  174. typedef cds::backoff::pause back_off;
  175. };
  176. };
  177. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  178. set_type s( kSize, 4 );
  179. test( s );
  180. }
  181. TEST_F( SplitListMichaelSet_NoGC, bit_reversal_swar )
  182. {
  183. struct set_traits: public cc::split_list::traits
  184. {
  185. typedef cc::michael_list_tag ordered_list;
  186. typedef hash_int hash;
  187. typedef cds::atomicity::item_counter item_counter;
  188. typedef cds::algo::bit_reversal::swar bit_reversal;
  189. struct ordered_list_traits: public cc::michael_list::traits
  190. {
  191. typedef cmp compare;
  192. typedef base_class::less less;
  193. typedef cds::backoff::empty back_off;
  194. };
  195. };
  196. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  197. set_type s( kSize, 2 );
  198. test( s );
  199. }
  200. TEST_F( SplitListMichaelSet_NoGC, bit_reversal_lookup )
  201. {
  202. struct set_traits: public cc::split_list::traits
  203. {
  204. typedef cc::michael_list_tag ordered_list;
  205. typedef hash_int hash;
  206. typedef cds::atomicity::item_counter item_counter;
  207. typedef cds::algo::bit_reversal::lookup bit_reversal;
  208. struct ordered_list_traits: public cc::michael_list::traits
  209. {
  210. typedef cmp compare;
  211. typedef base_class::less less;
  212. typedef cds::backoff::empty back_off;
  213. };
  214. };
  215. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  216. set_type s( kSize, 2 );
  217. test( s );
  218. }
  219. TEST_F( SplitListMichaelSet_NoGC, bit_reversal_muldiv )
  220. {
  221. struct set_traits: public cc::split_list::traits
  222. {
  223. typedef cc::michael_list_tag ordered_list;
  224. typedef hash_int hash;
  225. typedef cds::atomicity::item_counter item_counter;
  226. typedef cds::algo::bit_reversal::muldiv bit_reversal;
  227. struct ordered_list_traits: public cc::michael_list::traits
  228. {
  229. typedef cmp compare;
  230. typedef base_class::less less;
  231. typedef cds::backoff::empty back_off;
  232. };
  233. };
  234. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  235. set_type s( kSize, 2 );
  236. test( s );
  237. }
  238. } // namespace