QDeadlineTimer: make the ForeverConstant an enum class
Avoids the implicit cast to int, which then fixes the overloading problem of QDeadlineTimer with older functions taking an integer with the number of milliseconds. Without this and the workarounds, an expression like waitCondition.wait(&mutex, QDeadlineTimer::Forever); would be the same as waitCondition.wait(&mutex, 0); which is the opposite of "forever". This means we can remove the overloads added earlier this week in commits37f1fb78ee
(QMutex),63704529b7
(QReadWriteLock), and37f1fb78ee
(QSemaphore). I hadn't thought this solution until noting that QWaitCondition needed the same solution and then remembering how Qt::Uninitialized was fixed of the same problem. Change-Id: I5f7f427ded124479baa6fffd176023ddfb91077d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
b5c9eec15c
commit
5f531ae2ac
@ -23,7 +23,8 @@ QT_BEGIN_NAMESPACE
|
||||
class Q_CORE_EXPORT QDeadlineTimer
|
||||
{
|
||||
public:
|
||||
enum ForeverConstant { Forever };
|
||||
enum class ForeverConstant { Forever };
|
||||
static constexpr ForeverConstant Forever = ForeverConstant::Forever;
|
||||
|
||||
constexpr QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) noexcept
|
||||
: type(type_) {}
|
||||
|
@ -145,12 +145,6 @@ public:
|
||||
return success;
|
||||
}
|
||||
|
||||
#ifndef Q_QDOC
|
||||
// because tryLock(QDeadlineTimer::Forever) is tryLock(0)
|
||||
bool tryLock(QDeadlineTimer::ForeverConstant) QT_MUTEX_LOCK_NOEXCEPT
|
||||
{ lock(); return true; }
|
||||
#endif
|
||||
|
||||
// TimedLockable concept
|
||||
template <class Rep, class Period>
|
||||
bool try_lock_for(std::chrono::duration<Rep, Period> duration)
|
||||
|
@ -43,15 +43,6 @@ public:
|
||||
|
||||
void unlock();
|
||||
|
||||
#ifndef Q_QDOC
|
||||
// because tryLockForXxx(QDeadlineTimer::Forever) is the same
|
||||
// as tryLockForXxx(0), which is not forever
|
||||
bool tryLockForRead(QDeadlineTimer::ForeverConstant)
|
||||
{ lockForRead(); return true; }
|
||||
bool tryLockForWrite(QDeadlineTimer::ForeverConstant)
|
||||
{ lockForWrite(); return true; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QReadWriteLock)
|
||||
QAtomicPointer<QReadWriteLockPrivate> d_ptr;
|
||||
|
@ -23,11 +23,6 @@ public:
|
||||
QT_CORE_INLINE_SINCE(6, 6)
|
||||
bool tryAcquire(int n, int timeout);
|
||||
bool tryAcquire(int n, QDeadlineTimer timeout);
|
||||
#ifndef Q_QDOC
|
||||
// because tryAcquire(n, QDeadlineTimer::Forever) is tryLock(n, 0)
|
||||
bool tryAcquire(int n, QDeadlineTimer::ForeverConstant)
|
||||
{ acquire(n); return true; }
|
||||
#endif
|
||||
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
|
||||
template <typename Rep, typename Period>
|
||||
bool tryAcquire(int n, std::chrono::duration<Rep, Period> timeout)
|
||||
|
Loading…
Reference in New Issue
Block a user