QRecursiveMutex: make tryLock(QDeadlineTimer) the default (was: int)

The default argument staying on the old int overload meant that on
Windows a nullary tryLock() call would need to go through both DLL-
exported functions (int, then QDeadlineTimer) and on non-Windows
platforms, it would hit the out-of-line QDeadlineTimer(qint64)
ctor.

By moving the default argument from the old to the new function, we
reduce the nullary call on Windows from two to one exported functions.
On non-Windows, we make it to hit QDeadlineTimer's constexpr inline
default ctor instead.

Found in API-review.

Amends ff9da1db0b0963f967f45ab430ec40a3051b70b4.

Change-Id: Id3e9923cf97ee1673fe05c85c30b5a12531857b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f780893c39d6090e804c8caeb08af4f919777109)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-08-18 20:35:57 +02:00 committed by Qt Cherry-pick Bot
parent 566aede35f
commit 4df46fd72c

View File

@ -181,8 +181,8 @@ public:
void lock() QT_MUTEX_LOCK_NOEXCEPT
{ tryLock(QDeadlineTimer(QDeadlineTimer::Forever)); }
QT_CORE_INLINE_SINCE(6, 6)
bool tryLock(int timeout = 0) QT_MUTEX_LOCK_NOEXCEPT;
bool tryLock(QDeadlineTimer timer) QT_MUTEX_LOCK_NOEXCEPT;
bool tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT;
bool tryLock(QDeadlineTimer timer = {}) QT_MUTEX_LOCK_NOEXCEPT;
// BasicLockable concept
void unlock() noexcept;