3 #ifndef __CDS_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_H
4 #define __CDS_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_H
6 #include <cds/container/split_list_base.h>
7 #include <cds/details/allocator.h>
8 #include <cds/details/binary_functor_wrapper.h>
11 namespace cds { namespace container {
13 // Forward declaration
14 struct michael_list_tag;
19 #ifdef __CDS_CONTAINER_MICHAEL_LIST_BASE_H
20 // if michael_list included
22 template <typename GC, typename T, typename Traits>
23 struct make_split_list_set< GC, T, michael_list_tag, Traits >
27 typedef Traits original_type_traits;
29 typedef typename cds::opt::select_default<
30 typename original_type_traits::ordered_list_traits,
31 cds::container::michael_list::type_traits
32 >::type original_ordered_list_traits;
34 typedef cds::intrusive::split_list::node< cds::intrusive::michael_list::node<gc> > primary_node_type;
35 struct node_type: public primary_node_type
40 explicit node_type( Q const& v )
43 # ifdef CDS_EMPLACE_SUPPORT
44 template <typename Q, typename... Args>
45 explicit node_type( Q&& q, Args&&... args )
46 : m_Value( std::forward<Q>(q), std::forward<Args>(args)... )
50 node_type() ; // no default ctor
53 typedef typename cds::opt::select_default<
54 typename original_type_traits::ordered_list_traits,
55 typename original_type_traits::allocator,
56 typename cds::opt::select_default<
57 typename original_type_traits::ordered_list_traits::allocator,
58 typename original_type_traits::allocator
60 >::type node_allocator_;
62 typedef typename node_allocator_::template rebind<node_type>::other node_allocator_type;
64 typedef cds::details::Allocator< node_type, node_allocator_type > cxx_node_allocator;
65 struct node_deallocator
67 void operator ()( node_type * pNode )
69 cxx_node_allocator().Delete( pNode );
73 typedef typename opt::details::make_comparator< value_type, original_ordered_list_traits >::type key_comparator;
75 typedef typename original_type_traits::key_accessor key_accessor;
79 typename key_accessor::key_type const& operator()( node_type const& node ) const
81 return key_accessor()(node.m_Value);
85 template <typename Predicate>
86 struct predicate_wrapper {
87 typedef cds::details::predicate_wrapper< node_type, Predicate, value_accessor > type;
90 struct ordered_list_traits: public original_ordered_list_traits
92 typedef cds::intrusive::michael_list::base_hook<
95 typedef atomicity::empty_item_counter item_counter;
96 typedef node_deallocator disposer;
97 typedef cds::details::compare_wrapper< node_type, key_comparator, value_accessor > compare;
100 struct type_traits: public original_type_traits
102 struct hash: public original_type_traits::hash
104 typedef typename original_type_traits::hash base_class;
106 size_t operator()(node_type const& v ) const
108 return base_class::operator()( key_accessor()( v.m_Value ) );
110 template <typename Q>
111 size_t operator()( Q const& k ) const
113 return base_class::operator()( k );
115 //using base_class::operator();
119 typedef cds::intrusive::MichaelList< gc, node_type, ordered_list_traits > ordered_list;
120 typedef cds::intrusive::SplitListSet< gc, ordered_list, type_traits > type;
122 #endif // ifdef __CDS_CONTAINER_MICHAEL_LIST_BASE_H
124 #ifdef __CDS_CONTAINER_LAZY_LIST_BASE_H
125 // if lazy_list included
126 template <typename GC, typename T, typename Traits>
127 struct make_split_list_set< GC, T, lazy_list_tag, Traits >
130 typedef T value_type;
131 typedef Traits original_type_traits;
133 typedef typename cds::opt::select_default<
134 typename original_type_traits::ordered_list_traits,
135 cds::container::lazy_list::type_traits
136 >::type original_ordered_list_traits;
138 typedef typename cds::opt::select_default<
139 typename original_ordered_list_traits::lock_type,
140 typename cds::container::lazy_list::type_traits::lock_type
143 typedef cds::intrusive::split_list::node< cds::intrusive::lazy_list::node<gc, lock_type > > primary_node_type;
144 struct node_type: public primary_node_type
148 template <typename Q>
149 explicit node_type( const Q& v )
153 # ifdef CDS_EMPLACE_SUPPORT
154 template <typename Q, typename... Args>
155 explicit node_type( Q&& q, Args&&... args )
156 : m_Value( std::forward<Q>(q), std::forward<Args>(args)... )
160 node_type() ; // no default ctor
163 typedef typename cds::opt::select_default<
164 typename original_type_traits::ordered_list_traits,
165 typename original_type_traits::allocator,
166 typename cds::opt::select_default<
167 typename original_type_traits::ordered_list_traits::allocator,
168 typename original_type_traits::allocator
170 >::type node_allocator_;
172 typedef typename node_allocator_::template rebind<node_type>::other node_allocator_type;
174 typedef cds::details::Allocator< node_type, node_allocator_type > cxx_node_allocator;
175 struct node_deallocator
177 void operator ()( node_type * pNode )
179 cxx_node_allocator().Delete( pNode );
183 typedef typename opt::details::make_comparator< value_type, original_ordered_list_traits >::type key_comparator;
185 typedef typename original_type_traits::key_accessor key_accessor;
187 struct value_accessor
189 typename key_accessor::key_type const & operator()( node_type const & node ) const
191 return key_accessor()(node.m_Value);
195 template <typename Predicate>
196 struct predicate_wrapper {
197 typedef cds::details::predicate_wrapper< node_type, Predicate, value_accessor > type;
200 struct ordered_list_traits: public original_ordered_list_traits
202 typedef cds::intrusive::lazy_list::base_hook<
204 ,opt::lock_type< lock_type >
206 typedef atomicity::empty_item_counter item_counter;
207 typedef node_deallocator disposer;
208 typedef cds::details::compare_wrapper< node_type, key_comparator, value_accessor > compare;
211 struct type_traits: public original_type_traits
213 struct hash: public original_type_traits::hash
215 typedef typename original_type_traits::hash base_class;
217 size_t operator()(node_type const& v ) const
219 return base_class::operator()( key_accessor()( v.m_Value ));
221 template <typename Q>
222 size_t operator()( Q const& k ) const
224 return base_class::operator()( k );
226 //using base_class::operator();
230 typedef cds::intrusive::LazyList< gc, node_type, ordered_list_traits > ordered_list;
231 typedef cds::intrusive::SplitListSet< gc, ordered_list, type_traits > type;
233 #endif // ifdef __CDS_CONTAINER_LAZY_LIST_BASE_H
235 } // namespace details
236 }} // namespace cds::container
239 #endif // #ifndef __CDS_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_H