Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::sync::shared_mutex_wrapper Class Reference

Shared mutex wrapper with reader-writer lock semantics. More...

#include <sync_primitives.h>

Collaboration diagram for kcenon::thread::sync::shared_mutex_wrapper:
Collaboration graph

Public Member Functions

 shared_mutex_wrapper ()=default
 
 ~shared_mutex_wrapper ()=default
 
 shared_mutex_wrapper (const shared_mutex_wrapper &)=delete
 
shared_mutex_wrapperoperator= (const shared_mutex_wrapper &)=delete
 
 shared_mutex_wrapper (shared_mutex_wrapper &&)=delete
 
shared_mutex_wrapperoperator= (shared_mutex_wrapper &&)=delete
 
void lock ()
 Acquire exclusive (writer) lock.
 
bool try_lock ()
 Try to acquire exclusive (writer) lock.
 
void unlock ()
 Release exclusive (writer) lock.
 
void lock_shared ()
 Acquire shared (reader) lock.
 
bool try_lock_shared ()
 Try to acquire shared (reader) lock.
 
void unlock_shared ()
 Release shared (reader) lock.
 
 shared_mutex_wrapper ()=default
 
 ~shared_mutex_wrapper ()=default
 
 shared_mutex_wrapper (const shared_mutex_wrapper &)=delete
 
shared_mutex_wrapperoperator= (const shared_mutex_wrapper &)=delete
 
 shared_mutex_wrapper (shared_mutex_wrapper &&)=delete
 
shared_mutex_wrapperoperator= (shared_mutex_wrapper &&)=delete
 
void lock ()
 Acquire exclusive (writer) lock.
 
bool try_lock ()
 Try to acquire exclusive (writer) lock.
 
void unlock ()
 Release exclusive (writer) lock.
 
void lock_shared ()
 Acquire shared (reader) lock.
 
bool try_lock_shared ()
 Try to acquire shared (reader) lock.
 
void unlock_shared ()
 Release shared (reader) lock.
 

Private Attributes

std::shared_mutex mutex_
 

Detailed Description

Shared mutex wrapper with reader-writer lock semantics.

Definition at line 236 of file sync_primitives.h.

Constructor & Destructor Documentation

◆ shared_mutex_wrapper() [1/6]

kcenon::thread::sync::shared_mutex_wrapper::shared_mutex_wrapper ( )
default

◆ ~shared_mutex_wrapper() [1/2]

kcenon::thread::sync::shared_mutex_wrapper::~shared_mutex_wrapper ( )
default

◆ shared_mutex_wrapper() [2/6]

kcenon::thread::sync::shared_mutex_wrapper::shared_mutex_wrapper ( const shared_mutex_wrapper & )
delete

◆ shared_mutex_wrapper() [3/6]

kcenon::thread::sync::shared_mutex_wrapper::shared_mutex_wrapper ( shared_mutex_wrapper && )
delete

◆ shared_mutex_wrapper() [4/6]

kcenon::thread::sync::shared_mutex_wrapper::shared_mutex_wrapper ( )
default

◆ ~shared_mutex_wrapper() [2/2]

kcenon::thread::sync::shared_mutex_wrapper::~shared_mutex_wrapper ( )
default

◆ shared_mutex_wrapper() [5/6]

kcenon::thread::sync::shared_mutex_wrapper::shared_mutex_wrapper ( const shared_mutex_wrapper & )
delete

◆ shared_mutex_wrapper() [6/6]

kcenon::thread::sync::shared_mutex_wrapper::shared_mutex_wrapper ( shared_mutex_wrapper && )
delete

Member Function Documentation

◆ lock() [1/2]

void kcenon::thread::sync::shared_mutex_wrapper::lock ( )
inline

Acquire exclusive (writer) lock.

Definition at line 244 of file sync_primitives.h.

244 {
245 mutex_.lock();
246 }

References mutex_.

◆ lock() [2/2]

void kcenon::thread::sync::shared_mutex_wrapper::lock ( )
inline

Acquire exclusive (writer) lock.

Definition at line 250 of file sync_primitives.h.

250 {
251 mutex_.lock();
252 }

References mutex_.

◆ lock_shared() [1/2]

void kcenon::thread::sync::shared_mutex_wrapper::lock_shared ( )
inline

Acquire shared (reader) lock.

Definition at line 266 of file sync_primitives.h.

266 {
267 mutex_.lock_shared();
268 }

References mutex_.

◆ lock_shared() [2/2]

void kcenon::thread::sync::shared_mutex_wrapper::lock_shared ( )
inline

Acquire shared (reader) lock.

Definition at line 272 of file sync_primitives.h.

272 {
273 mutex_.lock_shared();
274 }

References mutex_.

◆ operator=() [1/4]

shared_mutex_wrapper & kcenon::thread::sync::shared_mutex_wrapper::operator= ( const shared_mutex_wrapper & )
delete

◆ operator=() [2/4]

shared_mutex_wrapper & kcenon::thread::sync::shared_mutex_wrapper::operator= ( const shared_mutex_wrapper & )
delete

◆ operator=() [3/4]

shared_mutex_wrapper & kcenon::thread::sync::shared_mutex_wrapper::operator= ( shared_mutex_wrapper && )
delete

◆ operator=() [4/4]

shared_mutex_wrapper & kcenon::thread::sync::shared_mutex_wrapper::operator= ( shared_mutex_wrapper && )
delete

◆ try_lock() [1/2]

bool kcenon::thread::sync::shared_mutex_wrapper::try_lock ( )
inline

Try to acquire exclusive (writer) lock.

Returns
true if lock was acquired, false otherwise

Definition at line 252 of file sync_primitives.h.

252 {
253 return mutex_.try_lock();
254 }

References mutex_.

◆ try_lock() [2/2]

bool kcenon::thread::sync::shared_mutex_wrapper::try_lock ( )
inline

Try to acquire exclusive (writer) lock.

Returns
true if lock was acquired, false otherwise

Definition at line 258 of file sync_primitives.h.

258 {
259 return mutex_.try_lock();
260 }

References mutex_.

◆ try_lock_shared() [1/2]

bool kcenon::thread::sync::shared_mutex_wrapper::try_lock_shared ( )
inline

Try to acquire shared (reader) lock.

Returns
true if lock was acquired, false otherwise

Definition at line 274 of file sync_primitives.h.

274 {
275 return mutex_.try_lock_shared();
276 }

References mutex_.

◆ try_lock_shared() [2/2]

bool kcenon::thread::sync::shared_mutex_wrapper::try_lock_shared ( )
inline

Try to acquire shared (reader) lock.

Returns
true if lock was acquired, false otherwise

Definition at line 280 of file sync_primitives.h.

280 {
281 return mutex_.try_lock_shared();
282 }

References mutex_.

◆ unlock() [1/2]

void kcenon::thread::sync::shared_mutex_wrapper::unlock ( )
inline

Release exclusive (writer) lock.

Definition at line 259 of file sync_primitives.h.

259 {
260 mutex_.unlock();
261 }

References mutex_.

◆ unlock() [2/2]

void kcenon::thread::sync::shared_mutex_wrapper::unlock ( )
inline

Release exclusive (writer) lock.

Definition at line 265 of file sync_primitives.h.

265 {
266 mutex_.unlock();
267 }

References mutex_.

◆ unlock_shared() [1/2]

void kcenon::thread::sync::shared_mutex_wrapper::unlock_shared ( )
inline

Release shared (reader) lock.

Definition at line 281 of file sync_primitives.h.

281 {
282 mutex_.unlock_shared();
283 }

References mutex_.

◆ unlock_shared() [2/2]

void kcenon::thread::sync::shared_mutex_wrapper::unlock_shared ( )
inline

Release shared (reader) lock.

Definition at line 287 of file sync_primitives.h.

287 {
288 mutex_.unlock_shared();
289 }

References mutex_.

Member Data Documentation

◆ mutex_

std::shared_mutex kcenon::thread::sync::shared_mutex_wrapper::mutex_
private

Definition at line 286 of file sync_primitives.h.

Referenced by lock(), lock_shared(), try_lock(), try_lock_shared(), unlock(), and unlock_shared().


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