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>
This commit is contained in:
Giuseppe D'Angelo 2021-05-21 12:04:16 +02:00
parent 49c5724cb8
commit d598066dcf
2 changed files with 6 additions and 5 deletions

View File

@ -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();

View File

@ -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);