Class lockable

Class Documentation

class lockable

Simple class allowing explicit declaration that a derived class can be locked (un)conditionally in exclusive write and non-exclusive read-only contexts. Used mainly to reduce the if()s where possible.

Public Functions

lockable(const lockable&) = delete
lockable(lockable&&) = delete
lockable(void) = default
virtual ~lockable(void) = default
inline void lock_rd(std::shared_mutex *mtx) const

Unconditionally lock mtx for shared reader access.

inline void lock_wr(std::shared_mutex *mtx)

Unconditionally lock mtx for exclusive access.

inline void maybe_lock_rd(std::shared_mutex *mtx, bool cond) const

Lock mtx for read-only access if cond is TRUE. Other readers will still be allowed access to the resource.

inline void maybe_lock_wr(std::shared_mutex *mtx, bool cond)

Lock mtx for exclusive access if cond is TRUE.

inline void maybe_unlock_rd(std::shared_mutex *mtx, bool cond) const

Unlock mtx for read-only access if cond is TRUE.

inline void maybe_unlock_wr(std::shared_mutex *mtx, bool cond)

Unlock mtx for exclusive access if cond is TRUE.

const lockable &operator=(const lockable&) = delete
lockable &operator=(lockable&&) = delete
inline void unlock_rd(std::shared_mutex *mtx) const

Unconditionally unlock mtx for shared reader access.

inline void unlock_wr(std::shared_mutex *mtx)

Unconditionally unlock mtx for exclusive access.