From 20d0ff1a39c5f9c843f34b6dc1989df526a7367e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 6 Mar 2022 13:34:15 +0100 Subject: QMutexLocker: add move semantics The class is similar to unique_lock in that it allows for unlocking and relocking. Since the locked state is tracked by QMutexLocker itself, it's trivial to make it movable. [ChangeLog][QtCore][QMutexLocker] The class is now movable. Change-Id: I534044f8024575e996c12efb2236761d493798a3 Reviewed-by: Thiago Macieira Reviewed-by: Marc Mutz --- src/corelib/thread/qmutex.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/corelib/thread/qmutex.cpp') diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index dec0a95c47a..94e0fd25b16 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -485,6 +485,40 @@ void QRecursiveMutex::unlock() noexcept \sa QMutex::lock() */ +/*! + \fn template QMutexLocker::QMutexLocker(QMutexLocker &&other) noexcept + \since 6.4 + + Move-constructs a QMutexLocker from \a other. The mutex and the + state of \a other is transferred to the newly constructed instance. + After the move, \a other will no longer be managing its mutex. + + \sa QMutex::lock() +*/ + +/*! + \fn template QMutexLocker &QMutexLocker::operator=(QMutexLocker &&other) noexcept + \since 6.4 + + Move-assigns \a other onto this QMutexLocker. If this QMutexLocker + was holding a locked mutex before the assignment, the mutex will be + unlocked. The mutex and the state of \a other is then transferred + to this QMutexLocker. After the move, \a other will no longer be + managing its mutex. + + \sa QMutex::lock() +*/ + +/*! + \fn template void QMutexLocker::swap(QMutexLocker &other) noexcept + \since 6.4 + + Swaps the mutex and the state of this QMutexLocker with \a other. + This operation is very fast and never fails. + + \sa QMutex::lock() +*/ + /*! \fn template QMutexLocker::~QMutexLocker() noexcept -- cgit v1.2.3