57 template <
class LockType>
71 inline explicit GenericScopedLock (
const LockType& lock) noexcept : lock_ (lock) { lock.enter(); }
82 const LockType& lock_;
128 template <
class LockType>
157 const LockType& lock_;
200 template <
class LockType>
222 : lock_ (lock), lockWasSuccessful (acquireLockOnInitialisation && lock.tryEnter()) {}
235 bool isLocked() const noexcept {
return lockWasSuccessful; }
238 bool retryLock() const noexcept { lockWasSuccessful = lock_.tryEnter();
return lockWasSuccessful; }
242 const LockType& lock_;
243 mutable bool lockWasSuccessful;
Automatically locks and unlocks a mutex object.
GenericScopedLock(const LockType &lock) noexcept
Creates a GenericScopedLock.
~GenericScopedLock() noexcept
Destructor.
Automatically locks and unlocks a mutex object.
GenericScopedTryLock(const LockType &lock, bool acquireLockOnInitialisation=true) noexcept
Creates a GenericScopedTryLock.
bool isLocked() const noexcept
Returns true if the mutex was successfully locked.
bool retryLock() const noexcept
Retry gaining the lock by calling tryEnter on the underlying lock.
~GenericScopedTryLock() noexcept
Destructor.
Automatically unlocks and re-locks a mutex object.
~GenericScopedUnlock() noexcept
Destructor.
GenericScopedUnlock(const LockType &lock) noexcept
Creates a GenericScopedUnlock.