cds  2.3.2
cds::intrusive::striped_set::striping< Lock, Alloc > Class Template Reference

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_typelock_array_type
 lock array type
 

Public Member Functions

 striping (size_t nLockCount)
 Constructor. More...
 
size_t lock_count () const
 Returns lock array size. More...
 

Detailed Description

template<class Lock = std::mutex, class Alloc = CDS_DEFAULT_ALLOCATOR>
class cds::intrusive::striped_set::striping< Lock, Alloc >

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.

Constructor & Destructor Documentation

◆ striping()

template<class Lock = std::mutex, class Alloc = CDS_DEFAULT_ALLOCATOR>
cds::intrusive::striped_set::striping< Lock, Alloc >::striping ( size_t  nLockCount)
inline

Constructor.

Parameters
nLockCountThe size of lock array. Must be power of two.

Member Function Documentation

◆ lock_count()

template<class Lock = std::mutex, class Alloc = CDS_DEFAULT_ALLOCATOR>
size_t cds::intrusive::striped_set::striping< Lock, Alloc >::lock_count ( ) const
inline

Returns lock array size.

Lock array size is unchanged during striped object lifetime


The documentation for this class was generated from the following file:

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:48 by Doxygen 1.8.13