HDLC-Daemon
|
#include <LockGuard.h>
Public Member Functions | |
LockGuard () | |
The constructor of LockGuard objects. More... | |
~LockGuard () | |
The destructor of LockGuard objects. More... | |
void | Init (std::shared_ptr< SerialPortHandler > a_SerialPortHandler) |
Initializer method to register subsequent objects. More... | |
void | AcquireLock () |
Method to aquire a lock. More... | |
void | ReleaseLock () |
Method to release a lock. More... | |
bool | UpdateSerialPortState (size_t a_LockHolders) |
Update the effective lock state of the related serial port. More... | |
bool | IsLocked () const |
Query the lock state of the related serial device. More... | |
bool | IsLockedBySelf () const |
Query whether the serial device is currently "locked" by the responsible AccessClient entity. More... | |
bool | IsLockedByOthers () const |
Query whether the serial device is currently "locked" by at least one other AccessClient entity. More... | |
Class LockGuard.
This guard object tracks whether a related device attached via serial connections is currently "locked" / suspended or "unlocked" / resumed
Definition at line 35 of file LockGuard.h.
LockGuard::LockGuard | ( | ) |
The constructor of LockGuard objects.
On creation, the serial port is "unlocked" / resumed
Definition at line 31 of file LockGuard.cpp.
LockGuard::~LockGuard | ( | ) |
The destructor of LockGuard objects.
Held locks are automatically released on deletion
Definition at line 43 of file LockGuard.cpp.
void LockGuard::AcquireLock | ( | ) |
Method to aquire a lock.
Each ClientAcceptor can aquired a lock only once, subsequent calls have no impact. The serial port handler has a lock counter, so only the first lock attempt will suspend the serial port.
Definition at line 67 of file LockGuard.cpp.
void LockGuard::Init | ( | std::shared_ptr< SerialPortHandler > | a_SerialPortHandler | ) |
Initializer method to register subsequent objects.
Registers the serial port handler object that is not available yet on construction
a_SerialPortHandler | the serial port handler object |
Definition at line 55 of file LockGuard.cpp.
|
inline |
Query the lock state of the related serial device.
Query the lock state of the related serial device
Definition at line 56 of file LockGuard.h.
|
inline |
Query whether the serial device is currently "locked" by at least one other AccessClient entity.
Query whether the serial device is currently "locked" by at least one other AccessClient entity
Definition at line 72 of file LockGuard.h.
|
inline |
Query whether the serial device is currently "locked" by the responsible AccessClient entity.
Query whether the serial device is currently locked" by the responsible AccessClient entity
Definition at line 64 of file LockGuard.h.
void LockGuard::ReleaseLock | ( | ) |
Method to release a lock.
Each ClientAcceptor can release a held lock only once, subsequent calls have no impact. The serial port handler has a lock counter, so it may resume after this call, but this happens only if this was the last lock.
Definition at line 80 of file LockGuard.cpp.
bool LockGuard::UpdateSerialPortState | ( | size_t | a_LockHolders | ) |
Update the effective lock state of the related serial port.
This method gets the amount of locks regarding the related serial port. Thus, this entity is able to derive whether subsequent locks by other entities exist.
a_LockHolders | the amount of locks that currently force the related serial port to be suspended |
Definition at line 96 of file LockGuard.cpp.