Lock
class Lock
Functions
| Name | Description |
|---|---|
| Lock | Create a lock on a device. |
| Lock | Copy construction is disabled other : Move construction will invalidate the lock being moved. other : |
| ~Lock | The destructor unlocks the device the lock is held on if the lock is valid. |
| lock | Reacquire a lock if this lock was previously unlocked recursive: : allow recursive locking if true |
| unlock | Unlock this lock |
| valid | Returns if this lock is currently valid. |
| lock_impl | Perform locking. |
| unlock_impl | Simply calls the clearLock slot on the locked device if we are the lock-holder |
Function Details
Lock
Lock(std::weak_ptr<karabo::xms::SignalSlotable> sigSlot, const std::string& deviceId, bool recursive = false)
Create a lock on a device. Throws a karabo::util::LockException if the lock cannot be acquired
sigSlot:
: a SignalSlotable instance to use for locking the remote device
deviceId:
: the deviceId of the device to lock
recursive:
: allow recursive locking if true
Lock(Lock&& other)
Copy construction is disabled
other
:
Move construction will invalidate the lock being moved.
other
:
lock
void lock(bool recursive = false) const
Reacquire a lock if this lock was previously unlocked
recursive:
: allow recursive locking if true
lock_impl
void lock_impl(bool recursive) const
Perform locking. Calling this function leads to the following remote calls:
1) check if we are allowed to lock: the lockedBy field on the remote device is either empty, or if recursive == true contains the lock requestor's device id
2) request locking, e.g. set the lockedBy field. This can still fail if another device locked in between
3) check if we are the lock holder: lockedBy should now contain our device id
recursive:
: allow recursive locking if true
unlock
void unlock() const
Unlock this lock
unlock_impl
void unlock_impl() const
Simply calls the clearLock slot on the locked device if we are the lock-holder
valid
bool valid() const
Returns if this lock is currently valid. Note that the locked device will be queried through the distributed system when asking for lock validity.
~Lock
virtual ~Lock()
The destructor unlocks the device the lock is held on if the lock is valid. It is called explictly if the lock was stolen and will then throw a karabo::util::LockException