summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-05-21 12:04:16 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-06-08 22:41:58 +0200
commitd598066dcfdb8a8330f9df029172188d2296fed7 (patch)
tree2e645b3de5b35ed37decfc15f4ff8d1a3e64786a /src/corelib/thread
parent49c5724cb8eeebf8176b2122401716f8d11bcc11 (diff)
QFutureInterface(Base): code tidies
refT()/derefT() can be marked noexcept; we don't care about not overflowing the refcounter as a precondition. (This is BC, as no compiler mangles noexcept.) This in turn allows to mark a constructor calling refT() as noexcept. Driveby: mark also the same functions to not be `const` in Qt 7. They clearly are meant to modify *this, and constness only works because of the unmanaged (raw) d-pointer. Change-Id: I8d7d365640ff2e1cedc0a234c9abccdfc95ba6e3 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qfutureinterface.cpp4
-rw-r--r--src/corelib/thread/qfutureinterface.h7
2 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp
index 8906245191..9bb7d505e2 100644
--- a/src/corelib/thread/qfutureinterface.cpp
+++ b/src/corelib/thread/qfutureinterface.cpp
@@ -586,12 +586,12 @@ void QFutureInterfaceBase::swap(QFutureInterfaceBase &other) noexcept
qSwap(d, other.d);
}
-bool QFutureInterfaceBase::refT() const
+bool QFutureInterfaceBase::refT() const noexcept
{
return d->refCount.refT();
}
-bool QFutureInterfaceBase::derefT() const
+bool QFutureInterfaceBase::derefT() const noexcept
{
// Called from ~QFutureInterface
return !d || d->refCount.derefT();
diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h
index 6df15304fc..3a6fe86d76 100644
--- a/src/corelib/thread/qfutureinterface.h
+++ b/src/corelib/thread/qfutureinterface.h
@@ -178,8 +178,9 @@ public:
void swap(QFutureInterfaceBase &other) noexcept;
protected:
- bool refT() const;
- bool derefT() const;
+ // ### Qt 7: remove const from refT/derefT
+ bool refT() const noexcept;
+ bool derefT() const noexcept;
void reset();
void rethrowPossibleException();
public:
@@ -234,7 +235,7 @@ public:
refT();
}
QFutureInterface(const QFutureInterfaceBase &dd) : QFutureInterfaceBase(dd) { refT(); }
- QFutureInterface(QFutureInterfaceBase &&dd) : QFutureInterfaceBase(std::move(dd)) { refT(); }
+ QFutureInterface(QFutureInterfaceBase &&dd) noexcept : QFutureInterfaceBase(std::move(dd)) { refT(); }
QFutureInterface &operator=(const QFutureInterface &other)
{
QFutureInterface copy(other);