cds
2.3.2
|
Lock striping concurrent access policy. More...
#include <cds/intrusive/cuckoo_set.h>
Public Types | |
typedef RecursiveLock | lock_type |
lock type | |
typedef Alloc | allocator_type |
allocator type | |
typedef Stat | statistics_type |
Internal statistics type (striping_stat or empty_striping_stat) | |
typedef cds::sync::lock_array< lock_type, cds::sync::pow2_select_policy, allocator_type > | lock_array_type |
lock array type | |
Public Member Functions | |
striping (size_t nLockCount) | |
Constructor. More... | |
size_t | lock_count () const |
Returns lock array size. More... | |
constexpr unsigned int | arity () const noexcept |
Returns the arity of striping mutex policy. | |
statistics_type const & | statistics () const |
Returns internal statistics. | |
Static Public Attributes | |
static unsigned int const | c_nArity = Arity |
the arity | |
Lock striping concurrent access policy.
This is one of available opt::mutex_policy option type for CuckooSet
Lock striping is very simple technique. The cuckoo set consists of the bucket tables and the array of locks. There is single lock array for each bucket table, at least, the count of bucket table is 2. Initially, the capacity of lock array and each bucket table is the same. When set is resized, bucket table capacity will be doubled but lock array will not. The lock i
protects each bucket j
, where j = i mod L
, where L
- the size of lock array.
The policy contains an internal array of RecursiveLock
locks.
Template arguments:
RecursiveLock
- the type of recursive mutex. The default is std::recursive_mutex
. The mutex type should be default-constructible. Note that a recursive spin-lock is not suitable for lock striping for performance reason.Arity
- unsigned int constant that specifies an arity. The arity is the count of hash functors, i.e., the count of lock arrays. Default value is 2.Alloc
- allocator type used for lock array memory allocation. Default is CDS_DEFAULT_ALLOCATOR
.Stat
- internal statistics type. Note that this template argument is automatically selected by CuckooSet class according to its opt::stat
option.
|
inline |
Constructor.
nLockCount | The size of lock array. Must be power of two. |
|
inline |
Returns lock array size.
Lock array size is unchanged during striping
object lifetime