Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Foundation::Execution::Synchronized_Traits< MUTEX > Struct Template Reference

#include <Synchronized.h>

Static Public Attributes

static constexpr bool kIsRecursiveReadMutex
 
static constexpr bool kIsRecursiveLockMutex = same_as<MUTEX, recursive_mutex> or same_as<MUTEX, recursive_timed_mutex>
 
static constexpr bool kDbgTraceLockUnlockIfNameSet = qStroika_Foundation_Debug_DefaultTracingOn
 

Detailed Description

template<typename MUTEX = recursive_mutex>
struct Stroika::Foundation::Execution::Synchronized_Traits< MUTEX >

MUTEX: We chose to make the default MUTEX recursive_mutex - since most patterns of use will be supported by this safely.

To use timed-locks, use timed_recursive_mutex.

If recursion is not necessary, and for highest performance, SpinLock will often work best.

Example Usage
Wrap any object with Synchronized<> and it can be used similarly to the base type,...

or slightly faster, but possibly slower or less safe (depending on usage) Synchronized<String,Synchronized_Traits<SpinLock>> n;

Note
Use of SUPPORTS_SHARED_LOCKS has HIGH PERFORMANCE OVERHEAD, and only makes sense when you have read locks held for a long time (and multiple threads doing so).
See also
http://joeduffyblog.com/2009/02/11/readerwriter-locks-and-their-lack-of-applicability-to-finegrained-synchronization/
Note
To change the value of one of the constexpr or type members of Synchronized_Traits, use template specialization (or pass a completely different traits object to Synchronized<>).

Definition at line 89 of file Synchronized.h.

Member Data Documentation

◆ kIsRecursiveReadMutex

template<typename MUTEX = recursive_mutex>
constexpr bool Stroika::Foundation::Execution::Synchronized_Traits< MUTEX >::kIsRecursiveReadMutex
staticconstexpr
Initial value:
= same_as<MUTEX, recursive_mutex> or same_as<MUTEX, recursive_timed_mutex> or
same_as<MUTEX, shared_timed_mutex> or same_as<MUTEX, shared_mutex>

Used internally for assertions that the synchronized object is used safely. If you mean to use differently, specialize

Definition at line 95 of file Synchronized.h.

◆ kIsRecursiveLockMutex

template<typename MUTEX = recursive_mutex>
constexpr bool Stroika::Foundation::Execution::Synchronized_Traits< MUTEX >::kIsRecursiveLockMutex = same_as<MUTEX, recursive_mutex> or same_as<MUTEX, recursive_timed_mutex>
staticconstexpr

Used internally for assertions that the synchronized object is used safely. If you mean to use differently, specialize

Definition at line 101 of file Synchronized.h.

◆ kDbgTraceLockUnlockIfNameSet

template<typename MUTEX = recursive_mutex>
constexpr bool Stroika::Foundation::Execution::Synchronized_Traits< MUTEX >::kDbgTraceLockUnlockIfNameSet = qStroika_Foundation_Debug_DefaultTracingOn
staticconstexpr

If enabled, fTraceLocksName field available, and if its set, DbgTrace calls on lock/unlock.

Definition at line 106 of file Synchronized.h.


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