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_FELDMAN_HASHSET_BASE_H
32 #define CDSLIB_CONTAINER_DETAILS_FELDMAN_HASHSET_BASE_H
34 #include <cds/intrusive/details/feldman_hashset_base.h>
35 #include <cds/container/details/base.h>
37 namespace cds { namespace container {
38 /// \p FeldmanHashSet related definitions
39 /** @ingroup cds_nonintrusive_helper
41 namespace feldman_hashset {
42 /// Hash accessor option
44 @copydetails cds::intrusive::feldman_hashset::traits::hash_accessor
46 template <typename Accessor>
47 using hash_accessor = cds::intrusive::feldman_hashset::hash_accessor< Accessor >;
51 @copydetails cds::intrusive::feldman_hashset::traits::hash_size
53 template <size_t Size>
54 using hash_size = cds::intrusive::feldman_hashset::hash_size< Size >;
56 /// \p FeldmanHashSet internal statistics, see cds::intrusive::feldman_hashset::stat
57 template <typename EventCounter = cds::atomicity::event_counter>
58 using stat = cds::intrusive::feldman_hashset::stat< EventCounter >;
60 /// \p FeldmanHashSet empty internal statistics
61 typedef cds::intrusive::feldman_hashset::empty_stat empty_stat;
63 /// Bit-wise memcmp-based comparator for hash value \p T
65 using bitwise_compare = cds::intrusive::feldman_hashset::bitwise_compare< T >;
67 /// \p FeldmanHashSet level statistics
68 typedef cds::intrusive::feldman_hashset::level_statistics level_statistics;
70 /// \p FeldmanHashSet traits
73 /// Mandatory functor to get hash value from data node
75 @copydetails cds::intrusive::feldman_hashset::traits::hash_accessor
77 typedef cds::opt::none hash_accessor;
79 /// The size of hash value in bytes
81 @copydetails cds::intrusive::feldman_hashset::traits::hash_size
83 static CDS_CONSTEXPR size_t const hash_size = 0;
85 /// Hash comparing functor
87 @copydetails cds::intrusive::feldman_hashset::traits::compare
89 typedef cds::opt::none compare;
91 /// Specifies binary predicate used for hash compare.
93 @copydetails cds::intrusive::feldman_hashset::traits::less
95 typedef cds::opt::none less;
99 @copydetails cds::intrusive::feldman_hashset::traits::item_counter
101 typedef cds::atomicity::item_counter item_counter;
105 Default is \ref CDS_DEFAULT_ALLOCATOR
107 typedef CDS_DEFAULT_ALLOCATOR allocator;
109 /// Array node allocator
111 @copydetails cds::intrusive::feldman_hashset::traits::node_allocator
113 typedef CDS_DEFAULT_ALLOCATOR node_allocator;
115 /// C++ memory ordering model
117 @copydetails cds::intrusive::feldman_hashset::traits::memory_model
119 typedef cds::opt::v::relaxed_ordering memory_model;
121 /// Back-off strategy
122 typedef cds::backoff::Default back_off;
124 /// Internal statistics
126 @copydetails cds::intrusive::feldman_hashset::traits::stat
128 typedef empty_stat stat;
130 /// RCU deadlock checking policy (only for \ref cds_container_FeldmanHashSet_rcu "RCU-based FeldmanHashSet")
132 @copydetails cds::intrusive::feldman_hashset::traits::rcu_check_deadlock
134 typedef cds::opt::v::rcu_throw_deadlock rcu_check_deadlock;
137 /// Metafunction converting option list to \p feldman_hashset::traits
139 Supported \p Options are:
140 - \p feldman_hashset::hash_accessor - mandatory option, hash accessor functor.
141 @copydetails traits::hash_accessor
142 - \p feldman_hashset::hash_size - the size of hash value in bytes.
143 @copydetails traits::hash_size
144 - \p opt::allocator - item allocator
145 @copydetails traits::allocator
146 - \p opt::node_allocator - array node allocator.
147 @copydetails traits::node_allocator
148 - \p opt::compare - hash comparison functor. No default functor is provided.
149 If the option is not specified, the \p opt::less is used.
150 - \p opt::less - specifies binary predicate used for hash comparison.
151 @copydetails cds::container::feldman_hashset::traits::less
152 - \p opt::back_off - back-off strategy used. If the option is not specified, the \p cds::backoff::Default is used.
153 - \p opt::item_counter - the type of item counting feature.
154 @copydetails cds::intrusive::feldman_hashset::traits::item_counter
155 - \p opt::memory_model - C++ memory ordering model. Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
156 or \p opt::v::sequential_consistent (sequentially consisnent memory model).
157 - \p opt::stat - internal statistics. By default, it is disabled (\p feldman_hashset::empty_stat).
158 To enable it use \p feldman_hashset::stat
159 - \p opt::rcu_check_deadlock - a deadlock checking policy for \ref cds_intrusive_FeldmanHashSet_rcu "RCU-based FeldmanHashSet"
160 Default is \p opt::v::rcu_throw_deadlock
162 template <typename... Options>
165 # ifdef CDS_DOXYGEN_INVOKED
166 typedef implementation_defined type ; ///< Metafunction result
168 typedef typename cds::opt::make_options<
169 typename cds::opt::find_type_traits< traits, Options... >::type
174 } // namespace feldman_hashset
177 // Forward declaration
178 template < class GC, typename T, class Traits = cds::container::feldman_hashset::traits >
179 class FeldmanHashSet;
185 template <typename GC, typename T, typename Traits>
186 struct make_feldman_hashset
189 typedef T value_type;
190 typedef Traits original_traits;
192 typedef cds::details::Allocator< value_type, typename original_traits::allocator > cxx_node_allocator;
196 void operator()( value_type * p ) const
198 cxx_node_allocator().Delete( p );
202 struct intrusive_traits: public original_traits
204 typedef node_disposer disposer;
207 // Metafunction result
208 typedef cds::intrusive::FeldmanHashSet< GC, T, intrusive_traits > type;
210 } // namespace details
213 }} // namespace cds::container
215 #endif // #ifndef CDSLIB_CONTAINER_DETAILS_FELDMAN_HASHSET_BASE_H