SObjectizer  5.8
Loading...
Searching...
No Matches
so_5::rw_spinlock_t< Backoff > Class Template Reference

A simple multi-readers/single-writer spinlock (analog of std::shared_mutex). More...

#include <spinlocks.hpp>

Public Member Functions

 rw_spinlock_t ()
 
 rw_spinlock_t (const rw_spinlock_t &)=delete
 
rw_spinlock_toperator= (const rw_spinlock_t &)=delete
 
void lock_shared ()
 Lock object in shared mode.
 
void unlock_shared ()
 Unlock object locked in shared mode.
 
void lock ()
 Lock object in exclusive mode.
 
void unlock ()
 Unlock object locked in exclusive mode.
 

Private Attributes

std::atomic_uint_fast32_t m_counters
 

Static Private Attributes

static constexpr const std::uint_fast32_t unlocked = 0
 
static constexpr const std::uint_fast32_t write_lock = 1
 
static constexpr const std::uint_fast32_t read_lock = 2
 

Detailed Description

template<class Backoff>
class so_5::rw_spinlock_t< Backoff >

A simple multi-readers/single-writer spinlock (analog of std::shared_mutex).

Since
v.5.4.0

This implementation is based on Dmitry Vyukov implementation from LLVM code base: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_mutex.cc?revision=210345&view=markup

Definition at line 151 of file spinlocks.hpp.

Constructor & Destructor Documentation

◆ rw_spinlock_t() [1/2]

template<class Backoff >
so_5::rw_spinlock_t< Backoff >::rw_spinlock_t ( )
inline

Definition at line 161 of file spinlocks.hpp.

◆ rw_spinlock_t() [2/2]

template<class Backoff >
so_5::rw_spinlock_t< Backoff >::rw_spinlock_t ( const rw_spinlock_t< Backoff > & )
delete

Member Function Documentation

◆ lock()

template<class Backoff >
void so_5::rw_spinlock_t< Backoff >::lock ( )
inline

Lock object in exclusive mode.

Definition at line 195 of file spinlocks.hpp.

◆ lock_shared()

template<class Backoff >
void so_5::rw_spinlock_t< Backoff >::lock_shared ( )
inline

Lock object in shared mode.

Definition at line 171 of file spinlocks.hpp.

◆ operator=()

template<class Backoff >
rw_spinlock_t & so_5::rw_spinlock_t< Backoff >::operator= ( const rw_spinlock_t< Backoff > & )
delete

◆ unlock()

template<class Backoff >
void so_5::rw_spinlock_t< Backoff >::unlock ( )
inline

Unlock object locked in exclusive mode.

Definition at line 227 of file spinlocks.hpp.

◆ unlock_shared()

template<class Backoff >
void so_5::rw_spinlock_t< Backoff >::unlock_shared ( )
inline

Unlock object locked in shared mode.

Definition at line 188 of file spinlocks.hpp.

Member Data Documentation

◆ m_counters

template<class Backoff >
std::atomic_uint_fast32_t so_5::rw_spinlock_t< Backoff >::m_counters
private

Definition at line 154 of file spinlocks.hpp.

◆ read_lock

template<class Backoff >
const std::uint_fast32_t so_5::rw_spinlock_t< Backoff >::read_lock = 2
staticconstexprprivate

Definition at line 158 of file spinlocks.hpp.

◆ unlocked

template<class Backoff >
const std::uint_fast32_t so_5::rw_spinlock_t< Backoff >::unlocked = 0
staticconstexprprivate

Definition at line 156 of file spinlocks.hpp.

◆ write_lock

template<class Backoff >
const std::uint_fast32_t so_5::rw_spinlock_t< Backoff >::write_lock = 1
staticconstexprprivate

Definition at line 157 of file spinlocks.hpp.


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