cds
2.3.2
|
Lock striping concurrent access policy. More...
#include <cds/intrusive/striped_set/striping_policy.h>
Public Types | |
typedef Lock | lock_type |
lock type | |
typedef Alloc | allocator_type |
allocator type | |
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... | |
Lock striping concurrent access policy.
This is one of available opt::mutex_policy option type for StripedSet
Lock striping is very simple technique. The set consists of the bucket table and the array of locks. Initially, the capacity of lock array and 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 Lock
locks.
Template arguments:
Lock
- the type of mutex. The default is std::mutex
. The mutex type should be default-constructible. Note that a spin-lock is not so good suitable for lock striping for performance reason.Alloc
- allocator type used for lock array memory allocation. Default is CDS_DEFAULT_ALLOCATOR
.
|
inline |
Constructor.
nLockCount | The size of lock array. Must be power of two. |
|
inline |
Returns lock array size.
Lock array size is unchanged during striped
object lifetime