1#ifndef QX_EXCLUSIVE_ACCESS_H
2#define QX_EXCLUSIVE_ACCESS_H
13template<
typename AccessType,
typename Mutex>
14 requires any_of<Mutex, QMutex, QRecursiveMutex>
41 mAccess(std::exchange(other.mAccess,
nullptr)),
42 mMutex(std::exchange(other.mMutex,
nullptr)),
43 mLocked(std::exchange(other.mLocked,
false))
56 bool isLocked() const noexcept {
return mLocked; }
75 swap(mAccess, other.mAccess);
76 swap(mMutex, other.mMutex);
77 swap(mLocked, other.mLocked);
80 Mutex*
mutex()
const {
return mMutex; }
82 AccessType*
access() {
return mAccess; }
83 const AccessType*
access()
const {
return mAccess; }
85 AccessType&
operator*() { Q_ASSERT(mAccess);
return *mAccess; }
86 const AccessType&
operator*()
const { Q_ASSERT(mAccess);
return *mAccess; }
88 AccessType*
operator->() { Q_ASSERT(mAccess);
return mAccess; }
89 const AccessType*
operator->()
const { Q_ASSERT(mAccess);
return mAccess; }
The ExclusiveAccess template class is a convenience class that simplifies access to resources secured...
Definition qx-exclusiveaccess.h:16
ExclusiveAccess & operator=(ExclusiveAccess &&other) noexcept
Definition qx-exclusiveaccess.h:92
ExclusiveAccess(AccessType *data, Mutex *mutex) noexcept
Definition qx-exclusiveaccess.h:28
AccessType * access()
Definition qx-exclusiveaccess.h:82
AccessType & operator*()
Definition qx-exclusiveaccess.h:85
void unlock() noexcept
Definition qx-exclusiveaccess.h:58
void swap(ExclusiveAccess &other) noexcept
Definition qx-exclusiveaccess.h:72
void relock() noexcept
Definition qx-exclusiveaccess.h:65
const AccessType * access() const
Definition qx-exclusiveaccess.h:83
~ExclusiveAccess()
Definition qx-exclusiveaccess.h:48
bool isLocked() const noexcept
Definition qx-exclusiveaccess.h:56
const AccessType * operator->() const
Definition qx-exclusiveaccess.h:89
const AccessType & operator*() const
Definition qx-exclusiveaccess.h:86
AccessType * operator->()
Definition qx-exclusiveaccess.h:88
Mutex * mutex() const
Definition qx-exclusiveaccess.h:80
ExclusiveAccess(ExclusiveAccess &&other) noexcept
Definition qx-exclusiveaccess.h:40
The Qx namespace is the main namespace through which all non-global functionality of the Qx library i...
Definition qx-processwaiter.cpp:5
The qx-concepts header file provides a library of general purpose concepts as an extension of the sta...