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

Interface to allow synchronizing the access to derived classes between different threads by making the class lockable by SynchronizedPointer smart pointer objects. Recursive locking is allowed. More...

+ Inheritance diagram for Util::ISynchronizedPointerLockable:

Protected Member Functions

 ISynchronizedPointerLockable ()
 
 ~ISynchronizedPointerLockable ()
 Object should never be destroyed before completely unlocked. More...
 
- Protected Member Functions inherited from Util::INonCopyable
constexpr INonCopyable ()=default
 
 ~INonCopyable ()=default
 

Private Member Functions

void AcquireLock (const std::chrono::milliseconds Timeout) const
 Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded. Recursive locking is allowed. More...
 
void ReleaseLock () const
 Releases the internal mutex. Does nothing if the mutex was not locked or if the calling thread is not the current owner of the muetx. More...
 

Private Attributes

std::timed_mutex LockMutex
 Internal mutex used for locking. More...
 
std::atomic< std::thread::id > OwnerID
 ID of the thread which currently owns the internal mutex. More...
 
std::atomic< size_t > OwnedCount
 Counts the lock requests of the current owning thread. More...
 

Friends

template<typename >
class SynchronizedPointer
 

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 making the class lockable by SynchronizedPointer smart pointer objects. Recursive locking is allowed.

Definition at line 92 of file Util.h.

Constructor & Destructor Documentation

◆ ISynchronizedPointerLockable()

Util::ISynchronizedPointerLockable::ISynchronizedPointerLockable ( )
inlineprotected

Definition at line 99 of file Util.h.

◆ ~ISynchronizedPointerLockable()

Util::ISynchronizedPointerLockable::~ISynchronizedPointerLockable ( )
inlineprotected

Object should never be destroyed before completely unlocked.

Definition at line 100 of file Util.h.

Member Function Documentation

◆ AcquireLock()

void Util::ISynchronizedPointerLockable::AcquireLock ( const std::chrono::milliseconds  Timeout) const
inlineprivate

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

Parameters
TimeoutTime to wait trying to lock the internal mutex. 0 ms means that the functions waits for the mutex without timing out ever. Called by class SynchronizedPointer's constructor. So, default value is given there.
Exceptions
TimeoutExceptionis thrown if timeout duration is exceeded.

Definition at line 111 of file Util.h.

◆ ReleaseLock()

void Util::ISynchronizedPointerLockable::ReleaseLock ( ) const
inlineprivate

Releases the internal mutex. Does nothing if the mutex was not locked or if the calling thread is not the current owner of the muetx.

Definition at line 144 of file Util.h.

Friends And Related Function Documentation

◆ SynchronizedPointer

template<typename >
friend class SynchronizedPointer
friend

Definition at line 96 of file Util.h.

Member Data Documentation

◆ LockMutex

std::timed_mutex Util::ISynchronizedPointerLockable::LockMutex
mutableprivate

Internal mutex used for locking.

Definition at line 157 of file Util.h.

◆ OwnedCount

std::atomic<size_t> Util::ISynchronizedPointerLockable::OwnedCount
mutableprivate

Counts the lock requests of the current owning thread.

Definition at line 159 of file Util.h.

◆ OwnerID

std::atomic<std::thread::id> Util::ISynchronizedPointerLockable::OwnerID
mutableprivate

ID of the thread which currently owns the internal mutex.

Definition at line 158 of file Util.h.


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