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_ITERABLE_LIST_BASE_H
32 #define CDSLIB_CONTAINER_DETAILS_ITERABLE_LIST_BASE_H
34 #include <cds/container/details/base.h>
35 #include <cds/intrusive/details/iterable_list_base.h>
36 #include <cds/urcu/options.h>
38 namespace cds { namespace container {
40 /// \p IterableList ordered list related definitions
41 /** @ingroup cds_nonintrusive_helper
43 namespace iterable_list {
45 /// \p IterableList internal statistics, see \p cds::intrusive::iterable_list::stat
46 template <typename EventCounter = cds::intrusive::iterable_list::stat<>::event_counter >
47 using stat = cds::intrusive::iterable_list::stat< EventCounter >;
49 /// \p IterableList empty internal statistics, see \p cds::intrusive::iterable_list::empty_stat
50 typedef cds::intrusive::iterable_list::empty_stat empty_stat;
53 template <typename Stat = cds::intrusive::iterable_list::wrapped_stat<>::stat_type >
54 using wrapped_stat = cds::intrusive::iterable_list::wrapped_stat< Stat >;
57 /// \p IterableList traits
60 /// Allocator used to allocate new data
61 typedef CDS_DEFAULT_ALLOCATOR allocator;
64 typedef intrusive::iterable_list::traits::node_allocator node_allocator;
66 /// Key comparison functor
68 No default functor is provided. If the option is not specified, the \p less is used.
70 typedef opt::none compare;
72 /// Specifies binary predicate used for key comparison.
74 Default is \p std::less<T>.
76 typedef opt::none less;
79 typedef intrusive::iterable_list::traits::back_off back_off;
81 /// Item counting feature; by default, disabled. Use \p cds::atomicity::item_counter to enable item counting
82 typedef intrusive::iterable_list::traits::item_counter item_counter;
84 /// Internal statistics
86 By default, internal statistics is disabled (\p iterable_list::empty_stat).
87 Use \p iterable_list::stat to enable it.
89 typedef intrusive::iterable_list::traits::stat stat;
91 /// C++ memory ordering model
93 Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
94 or \p opt::v::sequential_consistent (sequentially consisnent memory model).
96 typedef opt::v::relaxed_ordering memory_model;
98 /// RCU deadlock checking policy (only for \ref cds_intrusive_MichaelList_rcu "RCU-based MichaelList")
100 List of available options see opt::rcu_check_deadlock
102 typedef opt::v::rcu_throw_deadlock rcu_check_deadlock;
105 // IterableKVList: supporting for split-ordered list
106 // key accessor (opt::none = internal key type is equal to user key type)
107 typedef opt::none key_accessor;
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::allocator - an allocator for data, default is \p CDS_DEFAULT_ALLOCATOR
118 - \p opt::node_allocator - node allocator, default is \p std::allocator.
119 - \p opt::back_off - back-off strategy used. If the option is not specified, the \p cds::backoff::Default is used.
120 - \p opt::item_counter - the type of item counting feature. Default is disabled (\p atomicity::empty_item_counter).
121 To enable item counting use \p atomicity::item_counter.
122 - \p opt::stat - internal statistics. By default, it is disabled (\p iterable_list::empty_stat).
123 To enable it use \p iterable_list::stat
124 - \p opt::memory_model - C++ memory ordering model. Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
125 or \p opt::v::sequential_consistent (sequentially consistent memory model).
126 - \p opt::rcu_check_deadlock - a deadlock checking policy for \ref cds_intrusive_IterableList_rcu "RCU-based IterableList"
127 Default is \p opt::v::rcu_throw_deadlock
129 template <typename... Options>
131 # ifdef CDS_DOXYGEN_INVOKED
132 typedef implementation_defined type ; ///< Metafunction result
134 typedef typename cds::opt::make_options<
135 typename cds::opt::find_type_traits< traits, Options... >::type
142 } // namespace iterable_list
144 // Forward declarations
145 template <typename GC, typename T, typename Traits=iterable_list::traits>
148 template <typename GC, typename Key, typename Value, typename Traits=iterable_list::traits>
149 class IterableKVList;
151 // Tag for selecting iterable list implementation
153 This struct is empty and it is used only as a tag for selecting \p IterableList
154 as ordered list implementation in declaration of some classes.
156 See split_list::traits::ordered_list as an example.
158 struct iterable_list_tag
162 template <typename List>
163 struct is_iterable_list {
169 template <typename GC, typename T, typename Traits>
170 struct is_iterable_list< IterableList<GC, T, Traits >>
177 template <typename GC, typename T, typename Traits>
178 struct is_iterable_list< IterableKVList<GC, T, Traits >>
186 }} // namespace cds::container
189 #endif // #ifndef CDSLIB_CONTAINER_DETAILS_ITERABLE_LIST_BASE_H