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_MICHAEL_LIST_H
32 #define CDSLIB_CONTAINER_DETAILS_MAKE_MICHAEL_LIST_H
34 #include <cds/details/binary_functor_wrapper.h>
36 namespace cds { namespace container {
41 template <class GC, typename T, class Traits>
42 struct make_michael_list
47 struct node_type : public intrusive::michael_list::node<gc>
55 node_type( Q const& v )
59 template <typename... Args>
60 node_type( Args&&... args )
61 : m_Value( std::forward<Args>(args)... )
65 typedef Traits original_traits;
67 typedef typename original_traits::allocator::template rebind<node_type>::other allocator_type;
68 typedef cds::details::Allocator< node_type, allocator_type > cxx_allocator;
70 struct node_deallocator
72 void operator ()( node_type * pNode )
74 cxx_allocator().Delete( pNode );
78 typedef typename opt::details::make_comparator< value_type, original_traits >::type key_comparator;
82 value_type const & operator()( node_type const& node ) const
88 template <typename Less>
90 typedef cds::details::compare_wrapper< node_type, cds::opt::details::make_comparator_from_less<Less>, value_accessor > type;
93 struct intrusive_traits: public original_traits
95 typedef intrusive::michael_list::base_hook< opt::gc<gc> > hook;
96 typedef node_deallocator disposer;
97 typedef cds::details::compare_wrapper< node_type, key_comparator, value_accessor > compare;
98 static CDS_CONSTEXPR const opt::link_check_type link_checker = cds::intrusive::michael_list::traits::link_checker;
101 typedef intrusive::MichaelList<gc, node_type, intrusive_traits> type;
103 } // namespace details
106 }} // namespace cds::container
108 #endif // #ifndef CDSLIB_CONTAINER_DETAILS_MAKE_MICHAEL_LIST_H