DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Util::ILockable Class Reference

Interface to allow synchronizing the access to derived classes between different threads by providing a mutex and a method to lock that mutex. Recursive locking is not allowed. More...

+ Inheritance diagram for Util::ILockable:

Static Public Attributes

static constexpr std::chrono::milliseconds DefaultTimeout = std::chrono::milliseconds(10)
 Duration which is used as a default timeout within all methods of this class if no different duration is passed to them. More...
 

Protected Types

using MutexType = std::timed_mutex
 
using LockType = std::unique_lock< MutexType >
 

Protected Member Functions

 ILockable ()=default
 
 ~ILockable ()=default
 
LockType AcquireLock (const std::chrono::milliseconds Timeout=DefaultTimeout) const
 Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded. More...
 
- Protected Member Functions inherited from Util::INonCopyable
constexpr INonCopyable ()=default
 
 ~INonCopyable ()=default
 

Private Attributes

MutexType LockMutex
 Internal mutex used for locking. More...
 

Additional Inherited Members

- Public Member Functions inherited from Util::INonCopyable
 INonCopyable (const INonCopyable &)=delete
 
INonCopyableoperator= (const INonCopyable &)=delete
 

Detailed Description

Interface to allow synchronizing the access to derived classes between different threads by providing a mutex and a method to lock that mutex. Recursive locking is not allowed.

Definition at line 55 of file Util.h.

Member Typedef Documentation

◆ LockType

using Util::ILockable::LockType = std::unique_lock<MutexType>
protected

Definition at line 66 of file Util.h.

◆ MutexType

using Util::ILockable::MutexType = std::timed_mutex
protected

Definition at line 65 of file Util.h.

Constructor & Destructor Documentation

◆ ILockable()

Util::ILockable::ILockable ( )
protecteddefault

◆ ~ILockable()

Util::ILockable::~ILockable ( )
protecteddefault

Member Function Documentation

◆ AcquireLock()

std::unique_lock< ILockable::MutexType > Util::ILockable::AcquireLock ( const std::chrono::milliseconds  Timeout = DefaultTimeout) const
protected

Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded.

Parameters
TimeoutTime to wait trying to lock the internal mutex. 0 ms means that the functions waits for the mutex without timing out ever.
Returns
Returns a lock guard which unlocks the locked mutex upon destruction.
Exceptions
TimeoutExceptionis thrown if timeout duration is exceeded.

Definition at line 8 of file Util.cpp.

Member Data Documentation

◆ DefaultTimeout

constexpr std::chrono::milliseconds Util::ILockable::DefaultTimeout = std::chrono::milliseconds(10)
staticconstexpr

Duration which is used as a default timeout within all methods of this class if no different duration is passed to them.

Definition at line 62 of file Util.h.

◆ LockMutex

MutexType Util::ILockable::LockMutex
mutableprivate

Internal mutex used for locking.

Definition at line 82 of file Util.h.


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