split_lazy_nogc.cpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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/lazy_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 SplitListLazySet_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( SplitListLazySet_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::lazy_list_tag >
  26. , cds::opt::hash< hash_int >
  27. , cc::split_list::ordered_list_traits<
  28. typename cc::lazy_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( SplitListLazySet_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::lazy_list_tag >
  42. , cds::opt::hash< hash_int >
  43. , cc::split_list::ordered_list_traits<
  44. typename cc::lazy_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( SplitListLazySet_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::lazy_list_tag >
  58. , cds::opt::hash< hash_int >
  59. , cc::split_list::ordered_list_traits<
  60. typename cc::lazy_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, 1 );
  68. test( s );
  69. }
  70. TEST_F( SplitListLazySet_NoGC, item_counting )
  71. {
  72. struct set_traits: public cc::split_list::traits
  73. {
  74. typedef cc::lazy_list_tag ordered_list;
  75. typedef hash_int hash;
  76. typedef cds::atomicity::item_counter item_counter;
  77. struct ordered_list_traits: public cc::lazy_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, 3 );
  86. test( s );
  87. }
  88. TEST_F( SplitListLazySet_NoGC, stat )
  89. {
  90. struct set_traits: public cc::split_list::traits
  91. {
  92. typedef cc::lazy_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::lazy_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, 4 );
  104. test( s );
  105. }
  106. TEST_F( SplitListLazySet_NoGC, back_off )
  107. {
  108. struct set_traits: public cc::split_list::traits
  109. {
  110. typedef cc::lazy_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::lazy_list::traits
  116. {
  117. typedef cmp compare;
  118. typedef cds::backoff::empty 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( SplitListLazySet_NoGC, mutex )
  126. {
  127. struct set_traits: public cc::split_list::traits
  128. {
  129. typedef cc::lazy_list_tag ordered_list;
  130. typedef hash_int hash;
  131. typedef cds::atomicity::item_counter item_counter;
  132. typedef cds::backoff::yield back_off;
  133. typedef cds::opt::v::sequential_consistent memory_model;
  134. struct ordered_list_traits: public cc::lazy_list::traits
  135. {
  136. typedef cmp compare;
  137. typedef cds::backoff::pause back_off;
  138. typedef std::mutex lock_type;
  139. };
  140. };
  141. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  142. set_type s( kSize, 3 );
  143. test( s );
  144. }
  145. struct set_static_traits: public cc::split_list::traits
  146. {
  147. static bool const dynamic_bucket_table = false;
  148. };
  149. TEST_F( SplitListLazySet_NoGC, static_bucket_table )
  150. {
  151. struct set_traits: public set_static_traits
  152. {
  153. typedef cc::lazy_list_tag ordered_list;
  154. typedef hash_int hash;
  155. typedef cds::atomicity::item_counter item_counter;
  156. struct ordered_list_traits: public cc::lazy_list::traits
  157. {
  158. typedef cmp compare;
  159. typedef cds::backoff::pause back_off;
  160. };
  161. };
  162. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  163. set_type s( kSize, 4 );
  164. test( s );
  165. }
  166. TEST_F( SplitListLazySet_NoGC, static_bucket_table_free_list )
  167. {
  168. struct set_traits: public set_static_traits
  169. {
  170. typedef cc::lazy_list_tag ordered_list;
  171. typedef hash_int hash;
  172. typedef cds::atomicity::item_counter item_counter;
  173. typedef cds::intrusive::FreeList free_list;
  174. struct ordered_list_traits: public cc::lazy_list::traits
  175. {
  176. typedef cmp compare;
  177. typedef cds::backoff::pause back_off;
  178. };
  179. };
  180. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  181. set_type s( kSize, 4 );
  182. test( s );
  183. }
  184. TEST_F( SplitListLazySet_NoGC, free_list )
  185. {
  186. struct set_traits: public cc::split_list::traits
  187. {
  188. typedef cc::lazy_list_tag ordered_list;
  189. typedef hash_int hash;
  190. typedef cds::atomicity::item_counter item_counter;
  191. typedef cds::intrusive::FreeList free_list;
  192. struct ordered_list_traits: public cc::lazy_list::traits
  193. {
  194. typedef cmp compare;
  195. typedef cds::backoff::empty back_off;
  196. };
  197. };
  198. typedef cc::SplitListSet< gc_type, int_item, set_traits > set_type;
  199. set_type s( kSize, 2 );
  200. test( s );
  201. }
  202. } // namespace