2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef CDSLIB_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_LAZY_LIST_H
32 #define CDSLIB_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_LAZY_LIST_H
35 namespace cds { namespace container { namespace details {
37 template <typename GC, typename T, typename Traits>
38 struct make_split_list_set< GC, T, lazy_list_tag, Traits >
42 typedef Traits original_traits;
44 typedef typename cds::opt::select_default<
45 typename original_traits::ordered_list_traits,
46 cds::container::lazy_list::traits
47 >::type original_ordered_list_traits;
49 typedef typename cds::opt::select_default<
50 typename original_ordered_list_traits::lock_type,
51 typename cds::container::lazy_list::traits::lock_type
54 typedef cds::intrusive::split_list::node< cds::intrusive::lazy_list::node<gc, lock_type > > primary_node_type;
55 struct node_type: public primary_node_type
60 explicit node_type( Q&& v )
61 : m_Value( std::forward<Q>( v ))
64 template <typename Q, typename... Args>
65 explicit node_type( Q&& q, Args&&... args )
66 : m_Value( std::forward<Q>(q), std::forward<Args>(args)... )
72 typedef typename cds::opt::select_default<
73 typename original_traits::ordered_list_traits,
74 typename original_traits::allocator,
75 typename cds::opt::select_default<
76 typename original_traits::ordered_list_traits::allocator,
77 typename original_traits::allocator
79 >::type node_allocator_;
81 typedef typename node_allocator_::template rebind<node_type>::other node_allocator_type;
83 typedef cds::details::Allocator< node_type, node_allocator_type > cxx_node_allocator;
84 struct node_deallocator
86 void operator ()( node_type * pNode )
88 cxx_node_allocator().Delete( pNode );
92 typedef typename opt::details::make_comparator< value_type, original_ordered_list_traits >::type key_comparator;
94 typedef typename original_traits::key_accessor key_accessor;
98 typename key_accessor::key_type const & operator()( node_type const & node ) const
100 return key_accessor()(node.m_Value);
104 template <typename Predicate>
105 struct predicate_wrapper {
106 typedef cds::details::predicate_wrapper< node_type, Predicate, value_accessor > type;
109 struct ordered_list_traits: public original_ordered_list_traits
111 typedef cds::intrusive::lazy_list::base_hook<
113 ,opt::lock_type< lock_type >
115 typedef cds::atomicity::empty_item_counter item_counter;
116 typedef node_deallocator disposer;
117 typedef cds::details::compare_wrapper< node_type, key_comparator, value_accessor > compare;
118 static CDS_CONSTEXPR const opt::link_check_type link_checker = cds::intrusive::lazy_list::traits::link_checker;
121 struct traits: public original_traits
123 struct hash: public original_traits::hash
125 typedef typename original_traits::hash base_class;
127 size_t operator()(node_type const& v ) const
129 return base_class::operator()( key_accessor()( v.m_Value ));
131 template <typename Q>
132 size_t operator()( Q const& k ) const
134 return base_class::operator()( k );
139 class ordered_list: public cds::intrusive::LazyList< gc, node_type, ordered_list_traits >
142 typedef cds::intrusive::SplitListSet< gc, ordered_list, traits > type;
144 }}} // namespace cds::container::details
147 #endif // #ifndef CDSLIB_CONTAINER_DETAILS_MAKE_SPLIT_LIST_SET_LAZY_LIST_H