583c72f0ed3cd0da44620b7bdbab48a58d2aece0
[libcds.git] / cds / container / details / lazy_list_base.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_CONTAINER_DETAILS_LAZY_LIST_BASE_H
4 #define __CDS_CONTAINER_DETAILS_LAZY_LIST_BASE_H
5
6 #include <cds/container/details/base.h>
7 #include <cds/intrusive/details/lazy_list_base.h>
8 #include <cds/urcu/options.h>
9
10 namespace cds { namespace container {
11
12     /// LazyList ordered list related definitions
13     /** @ingroup cds_nonintrusive_helper
14     */
15     namespace lazy_list {
16         /// LazyList traits
17         /**
18             Either \p compare or \p less or both must be specified.
19         */
20         struct traits
21         {
22             /// allocator used to allocate new node
23             typedef CDS_DEFAULT_ALLOCATOR   allocator;
24
25             /// Key comparing functor
26             /**
27                 No default functor is provided. If the option is not specified, the \p less is used.
28             */
29             typedef opt::none                       compare;
30
31             /// Specifies binary predicate used for key comparing
32             /**
33                 Default is \p std::less<T>.
34             */
35             typedef opt::none                       less;
36
37             /// Lock type used to lock modifying items
38             /**
39                 Default is cds::lock::Spin
40             */
41             typedef cds::lock::Spin                 lock_type;
42
43             /// back-off strategy used
44             typedef cds::backoff::Default           back_off;
45
46             /// Item counting feature; by default, disabled. Use \p cds::atomicity::item_counter to enable item counting
47             typedef atomicity::empty_item_counter     item_counter;
48
49             /// C++ memory ordering model
50             /**
51                 Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
52                 or \p opt::v::sequential_consistent (sequentially consisnent memory model).
53             */
54             typedef opt::v::relaxed_ordering        memory_model;
55
56             /// RCU deadlock checking policy (only for \ref cds_intrusive_LazyList_rcu "RCU-based LazyList")
57             /**
58                 List of available options see \p opt::rcu_check_deadlock
59             */
60             typedef opt::v::rcu_throw_deadlock      rcu_check_deadlock;
61
62             //@cond
63             // LazyKVList: supporting for split-ordered list
64             // key accessor (opt::none = internal key type is equal to user key type)
65             typedef opt::none                       key_accessor;
66
67             //@endcond
68         };
69
70         /// Metafunction converting option list to \p lazy_list::traits
71         /**
72             \p Options are:
73             - \p opt::lock_type - lock type for node-level locking. Default \p is cds::lock::Spin. Note that <b>each</b> node
74                 of the list has member of type \p lock_type, therefore, heavy-weighted locking primitive is not
75                 acceptable as candidate for \p lock_type.
76             - \p opt::compare - key compare functor. No default functor is provided.
77                 If the option is not specified, the \p opt::less is used.
78             - \p opt::less - specifies binary predicate used for key compare. Default is \p std::less<T>.
79             - \p opt::back_off - back-off strategy used. If the option is not specified, \p cds::backoff::Default is used.
80             - \p opt::item_counter - the type of item counting feature. Default is disabled (\p atomicity::empty_item_counter).
81                 To enable item counting use \p atomicity::item_counter.
82             - \p opt::allocator - the allocator used for creating and freeing list's item. Default is \ref CDS_DEFAULT_ALLOCATOR macro.
83             - \p opt::memory_model - C++ memory ordering model. Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
84                 or \p opt::v::sequential_consistent (sequentially consisnent memory model).
85         */
86         template <typename... Options>
87         struct make_traits {
88 #   ifdef CDS_DOXYGEN_INVOKED
89             typedef implementation_defined type ;   ///< Metafunction result
90 #   else
91             typedef typename cds::opt::make_options<
92                 typename cds::opt::find_type_traits< traits, Options... >::type
93                 ,Options...
94             >::type   type;
95 #endif
96         };
97
98
99     } // namespace lazy_list
100
101     // Forward declarations
102     template <typename GC, typename T, typename Traits=lazy_list::traits>
103     class LazyList;
104
105     template <typename GC, typename Key, typename Value, typename Traits=lazy_list::traits>
106     class LazyKVList;
107
108     // Tag for selecting lazy list implementation
109     /**
110         This struct is empty and it is used only as a tag for selecting LazyList
111         as ordered list implementation in declaration of some classes.
112
113         See \p split_list::traits::ordered_list as an example.
114     */
115     struct lazy_list_tag
116     {};
117
118 }}  // namespace cds::container
119
120
121 #endif  // #ifndef __CDS_CONTAINER_DETAILS_LAZY_LIST_BASE_H