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_INTRUSIVE_DETAILS_ITERABLE_LIST_BASE_H
32 #define CDSLIB_INTRUSIVE_DETAILS_ITERABLE_LIST_BASE_H
34 #include <type_traits>
35 #include <cds/intrusive/details/base.h>
36 #include <cds/opt/compare.h>
37 #include <cds/algo/atomic.h>
38 #include <cds/details/marked_ptr.h>
39 #include <cds/urcu/options.h>
41 namespace cds { namespace intrusive {
43 /// \p IterableList ordered list related definitions
44 /** @ingroup cds_intrusive_helper
46 namespace iterable_list {
52 typedef T value_type; ///< Value type
54 atomics::atomic< node* > next; ///< pointer to next node in the list
55 atomics::atomic< value_type* > data; ///< pointer to user data, \p nullptr if the node is free
63 node( value_type * pVal )
70 /// \p IterableList traits
73 /// Key comparison functor
75 No default functor is provided. If the option is not specified, the \p less is used.
77 typedef opt::none compare;
79 /// Specifies binary predicate used for key compare.
81 Default is \p std::less<T>
83 typedef opt::none less;
86 typedef CDS_DEFAULT_ALLOCATOR node_allocator;
89 typedef cds::backoff::Default back_off;
91 /// Disposer for removing items
92 typedef opt::v::empty_disposer disposer;
94 /// Item counting feature; by default, disabled. Use \p cds::atomicity::item_counter to enable item counting
95 typedef atomicity::empty_item_counter item_counter;
97 /// C++ memory ordering model
99 Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
100 or \p opt::v::sequential_consistent (sequentially consisnent memory model).
102 typedef opt::v::relaxed_ordering memory_model;
104 /// RCU deadlock checking policy (only for \ref cds_intrusive_IterableList_rcu "RCU-based IterableList")
106 List of available policy see \p opt::rcu_check_deadlock
108 typedef opt::v::rcu_throw_deadlock rcu_check_deadlock;
111 /// Metafunction converting option list to \p iterable_list::traits
113 Supported \p Options are:
114 - \p opt::compare - key comparison functor. No default functor is provided.
115 If the option is not specified, the \p opt::less is used.
116 - \p opt::less - specifies binary predicate used for key comparison. Default is \p std::less<T>.
117 - \p opt::node_allocator - node allocator, default is \p std::allocator.
118 - \p opt::back_off - back-off strategy used. If the option is not specified, the \p cds::backoff::Default is used.
119 - \p opt::disposer - the functor used for disposing removed items. Default is \p opt::v::empty_disposer. Due the nature
120 of GC schema the disposer may be called asynchronously.
121 - \p opt::item_counter - the type of item counting feature. Default is disabled (\p atomicity::empty_item_counter).
122 To enable item counting use \p atomicity::item_counter.
123 - \p opt::memory_model - C++ memory ordering model. Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
124 or \p opt::v::sequential_consistent (sequentially consistent memory model).
125 - \p opt::rcu_check_deadlock - a deadlock checking policy for \ref cds_intrusive_IterableList_rcu "RCU-based IterableList"
126 Default is \p opt::v::rcu_throw_deadlock
128 template <typename... Options>
130 # ifdef CDS_DOXYGEN_INVOKED
131 typedef implementation_defined type ; ///< Metafunction result
133 typedef typename cds::opt::make_options<
134 typename cds::opt::find_type_traits< traits, Options... >::type
140 } // namespace iterable_list
143 // Forward declaration
144 template < class GC, typename T, class Traits = iterable_list::traits >
149 }} // namespace cds::intrusive
151 #endif // #ifndef CDSLIB_INTRUSIVE_DETAILS_ITERABLE_LIST_BASE_H