YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
yaclib::SharedMutex< FIFO, ReadersFIFO > Class Template Referencefinal

SharedMutex for coroutines. More...

#include <shared_mutex.hpp>

Inheritance diagram for yaclib::SharedMutex< FIFO, ReadersFIFO >:
[legend]
Collaboration diagram for yaclib::SharedMutex< FIFO, ReadersFIFO >:
[legend]

Public Types

using Base = detail::SharedMutexImpl< FIFO, ReadersFIFO >
 

Public Member Functions

auto Lock () noexcept
 
auto LockShared () noexcept
 
auto TryGuard () noexcept
 
auto TryGuardShared () noexcept
 
auto Guard () noexcept
 
auto GuardShared () noexcept
 
bool TryLock () noexcept
 
bool TryLockShared () noexcept
 
void UnlockHere () noexcept
 
void UnlockHereShared () noexcept
 

Static Public Member Functions

template<typename To , typename From >
static autoCast (From &from) noexcept
 

Additional Inherited Members

- Protected Member Functions inherited from yaclib::detail::SharedMutexImpl< FIFO, ReadersFIFO >
bool TryLockSharedAwait () noexcept
 
bool TryLockAwait () noexcept
 
bool AwaitLockShared (BaseCore &curr) noexcept
 
bool AwaitLock (BaseCore &curr) noexcept
 
bool TryLockShared () noexcept
 
bool TryLock () noexcept
 
void UnlockHereShared () noexcept
 
void UnlockHere () noexcept
 

Detailed Description

template<bool FIFO = true, bool ReadersFIFO = false>
class yaclib::SharedMutex< FIFO, ReadersFIFO >

SharedMutex for coroutines.

Note
It does not block execution thread, only coroutine
It is fair, with any options, so it doesn't allow recursive read locking and it's not possible to some coroutine wait other coroutines forever.
When we resume readers, we resume them all, no matter what options specified. Because otherwise will be more critical sections and I don't think it's good. If for some reason you need such behavior please use Semaphore.

TODO(MBkkt) benchmark different options

Template Parameters
FIFO– if true readers and writers in "single" queue, on practice with false it will alternate writers and readers
ReadersFIFO– readers resume order
WritersFIFO– writers lock acquiring order Configs: 1 0 – default, cares about honest order between critical sections that not intersects, but doesn't cares for other! 0 0 – cares only about throughput and liveness 1 1 – cares in first priority about order of critical sections 0 1 – opposite to default, but it's usefullness is doubtful

Definition at line 202 of file shared_mutex.hpp.

Member Typedef Documentation

◆ Base

template<bool FIFO = true, bool ReadersFIFO = false>
using yaclib::SharedMutex< FIFO, ReadersFIFO >::Base = detail::SharedMutexImpl<FIFO, ReadersFIFO>

Definition at line 204 of file shared_mutex.hpp.

Member Function Documentation

◆ Cast()

template<bool FIFO = true, bool ReadersFIFO = false>
template<typename To , typename From >
static auto & yaclib::SharedMutex< FIFO, ReadersFIFO >::Cast ( From &  from)
inlinestaticnoexcept

Definition at line 243 of file shared_mutex.hpp.

References yaclib::MakeContract().

◆ Guard()

template<bool FIFO = true, bool ReadersFIFO = false>
auto yaclib::SharedMutex< FIFO, ReadersFIFO >::Guard ( )
inlinenoexcept

Definition at line 232 of file shared_mutex.hpp.

◆ GuardShared()

template<bool FIFO = true, bool ReadersFIFO = false>
auto yaclib::SharedMutex< FIFO, ReadersFIFO >::GuardShared ( )
inlinenoexcept

Definition at line 236 of file shared_mutex.hpp.

◆ Lock()

template<bool FIFO = true, bool ReadersFIFO = false>
auto yaclib::SharedMutex< FIFO, ReadersFIFO >::Lock ( )
inlinenoexcept

Definition at line 216 of file shared_mutex.hpp.

◆ LockShared()

template<bool FIFO = true, bool ReadersFIFO = false>
auto yaclib::SharedMutex< FIFO, ReadersFIFO >::LockShared ( )
inlinenoexcept

Definition at line 220 of file shared_mutex.hpp.

◆ TryGuard()

template<bool FIFO = true, bool ReadersFIFO = false>
auto yaclib::SharedMutex< FIFO, ReadersFIFO >::TryGuard ( )
inlinenoexcept

Definition at line 224 of file shared_mutex.hpp.

◆ TryGuardShared()

template<bool FIFO = true, bool ReadersFIFO = false>
auto yaclib::SharedMutex< FIFO, ReadersFIFO >::TryGuardShared ( )
inlinenoexcept

Definition at line 228 of file shared_mutex.hpp.

◆ TryLock()

template<bool FIFO = true, bool ReadersFIFO = false>
bool yaclib::detail::SharedMutexImpl< FIFO, ReadersFIFO >::TryLock ( )
inlinenoexcept

Definition at line 67 of file shared_mutex.hpp.

◆ TryLockShared()

template<bool FIFO = true, bool ReadersFIFO = false>
bool yaclib::detail::SharedMutexImpl< FIFO, ReadersFIFO >::TryLockShared ( )
inlinenoexcept

Definition at line 57 of file shared_mutex.hpp.

◆ UnlockHere()

template<bool FIFO = true, bool ReadersFIFO = false>
void yaclib::detail::SharedMutexImpl< FIFO, ReadersFIFO >::UnlockHere ( )
inlinenoexcept

Definition at line 81 of file shared_mutex.hpp.

◆ UnlockHereShared()

template<bool FIFO = true, bool ReadersFIFO = false>
void yaclib::detail::SharedMutexImpl< FIFO, ReadersFIFO >::UnlockHereShared ( )
inlinenoexcept

Definition at line 71 of file shared_mutex.hpp.


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