3 #ifndef __CDS_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_H
4 #define __CDS_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_H
6 #include <cds/container/details/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 template <typename Q, typename... Args>
44 explicit node_type( Q&& q, Args&&... args )
45 : m_Value( std::forward<Q>(q), std::forward<Args>(args)... )
51 typedef typename cds::opt::select_default<
52 typename original_type_traits::ordered_list_traits,
53 typename original_type_traits::allocator,
54 typename cds::opt::select_default<
55 typename original_type_traits::ordered_list_traits::allocator,
56 typename original_type_traits::allocator
58 >::type node_allocator_;
60 typedef typename node_allocator_::template rebind<node_type>::other node_allocator_type;
62 typedef cds::details::Allocator< node_type, node_allocator_type > cxx_node_allocator;
63 struct node_deallocator
65 void operator ()( node_type * pNode )
67 cxx_node_allocator().Delete( pNode );
71 typedef typename opt::details::make_comparator< value_type, original_ordered_list_traits >::type key_comparator;
73 typedef typename original_type_traits::key_accessor key_accessor;
77 typename key_accessor::key_type const& operator()( node_type const& node ) const
79 return key_accessor()(node.m_Value);
83 template <typename Predicate>
84 struct predicate_wrapper {
85 typedef cds::details::predicate_wrapper< node_type, Predicate, value_accessor > type;
88 struct ordered_list_traits: public original_ordered_list_traits
90 typedef cds::intrusive::michael_list::base_hook<
93 typedef atomicity::empty_item_counter item_counter;
94 typedef node_deallocator disposer;
95 typedef cds::details::compare_wrapper< node_type, key_comparator, value_accessor > compare;
98 struct type_traits: public original_type_traits
100 struct hash: public original_type_traits::hash
102 typedef typename original_type_traits::hash base_class;
104 size_t operator()(node_type const& v ) const
106 return base_class::operator()( key_accessor()( v.m_Value ) );
108 template <typename Q>
109 size_t operator()( Q const& k ) const
111 return base_class::operator()( k );
113 //using base_class::operator();
117 typedef cds::intrusive::MichaelList< gc, node_type, ordered_list_traits > ordered_list;
118 typedef cds::intrusive::SplitListSet< gc, ordered_list, type_traits > type;
120 #endif // ifdef __CDS_CONTAINER_MICHAEL_LIST_BASE_H
122 #ifdef __CDS_CONTAINER_LAZY_LIST_BASE_H
123 // if lazy_list included
124 template <typename GC, typename T, typename Traits>
125 struct make_split_list_set< GC, T, lazy_list_tag, Traits >
128 typedef T value_type;
129 typedef Traits original_type_traits;
131 typedef typename cds::opt::select_default<
132 typename original_type_traits::ordered_list_traits,
133 cds::container::lazy_list::type_traits
134 >::type original_ordered_list_traits;
136 typedef typename cds::opt::select_default<
137 typename original_ordered_list_traits::lock_type,
138 typename cds::container::lazy_list::type_traits::lock_type
141 typedef cds::intrusive::split_list::node< cds::intrusive::lazy_list::node<gc, lock_type > > primary_node_type;
142 struct node_type: public primary_node_type
146 template <typename Q>
147 explicit node_type( const Q& v )
151 template <typename Q, typename... Args>
152 explicit node_type( Q&& q, Args&&... args )
153 : m_Value( std::forward<Q>(q), std::forward<Args>(args)... )
156 node_type() = delete;
159 typedef typename cds::opt::select_default<
160 typename original_type_traits::ordered_list_traits,
161 typename original_type_traits::allocator,
162 typename cds::opt::select_default<
163 typename original_type_traits::ordered_list_traits::allocator,
164 typename original_type_traits::allocator
166 >::type node_allocator_;
168 typedef typename node_allocator_::template rebind<node_type>::other node_allocator_type;
170 typedef cds::details::Allocator< node_type, node_allocator_type > cxx_node_allocator;
171 struct node_deallocator
173 void operator ()( node_type * pNode )
175 cxx_node_allocator().Delete( pNode );
179 typedef typename opt::details::make_comparator< value_type, original_ordered_list_traits >::type key_comparator;
181 typedef typename original_type_traits::key_accessor key_accessor;
183 struct value_accessor
185 typename key_accessor::key_type const & operator()( node_type const & node ) const
187 return key_accessor()(node.m_Value);
191 template <typename Predicate>
192 struct predicate_wrapper {
193 typedef cds::details::predicate_wrapper< node_type, Predicate, value_accessor > type;
196 struct ordered_list_traits: public original_ordered_list_traits
198 typedef cds::intrusive::lazy_list::base_hook<
200 ,opt::lock_type< lock_type >
202 typedef atomicity::empty_item_counter item_counter;
203 typedef node_deallocator disposer;
204 typedef cds::details::compare_wrapper< node_type, key_comparator, value_accessor > compare;
207 struct type_traits: public original_type_traits
209 struct hash: public original_type_traits::hash
211 typedef typename original_type_traits::hash base_class;
213 size_t operator()(node_type const& v ) const
215 return base_class::operator()( key_accessor()( v.m_Value ));
217 template <typename Q>
218 size_t operator()( Q const& k ) const
220 return base_class::operator()( k );
222 //using base_class::operator();
226 typedef cds::intrusive::LazyList< gc, node_type, ordered_list_traits > ordered_list;
227 typedef cds::intrusive::SplitListSet< gc, ordered_list, type_traits > type;
229 #endif // ifdef __CDS_CONTAINER_LAZY_LIST_BASE_H
231 } // namespace details
232 }} // namespace cds::container
235 #endif // #ifndef __CDS_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_H