5#include "private/qnumeric_p.h"
11using namespace std::chrono;
14struct TimeReference : std::numeric_limits<qint64>
17 static constexpr qint64 Max = max();
21template <
typename Duration1,
typename... Durations>
25 qint64 saturated = std::numeric_limits<qint64>::max();
27 saturated = std::numeric_limits<qint64>::min();
30 using Ratio = std::ratio_divide<typename Duration1::period, nanoseconds::period>;
31 static_assert(Ratio::den == 1,
"sub-multiples of nanosecond are not supported");
32 if (qMulOverflow<Ratio::num>(
v, &
v))
38 if constexpr (
sizeof...(Durations)) {
275 }
else if (msecs == 0) {
277 t1 = std::numeric_limits<qint64>::min();
279 *
this = current(timerType);
280 milliseconds ms(msecs);
311 }
else if (secs == 0 && nsecs == 0) {
313 t1 = std::numeric_limits<qint64>::min();
315 *
this = current(timerType);
367 if (
t1 == std::numeric_limits<qint64>::min())
418 return ceil<milliseconds>(nsecs).count();
433 qint64 raw = rawRemainingTimeNSecs();
434 return raw < 0 ? 0 : raw;
443qint64 QDeadlineTimer::rawRemainingTimeNSecs() const noexcept
445 if (
t1 == std::numeric_limits<qint64>::min())
478 return TimeReference::Max;
479 if (
t1 == TimeReference::Min)
483 return duration_cast<milliseconds>(
ns).count();
510 return TimeReference::Max;
530 if (msecs == TimeReference::Max) {
587 std::chrono::nanoseconds
ns = std::chrono::steady_clock::now().time_since_epoch();
static QDeadlineTimer current(Qt::TimerType timerType=Qt::CoarseTimer) noexcept
Returns a QDeadlineTimer that is expired but is guaranteed to contain the current time.
void setDeadline(qint64 msecs, Qt::TimerType timerType=Qt::CoarseTimer) noexcept
Sets the deadline for this QDeadlineTimer object to be the msecs absolute time point,...
void setRemainingTime(qint64 msecs, Qt::TimerType type=Qt::CoarseTimer) noexcept
Sets the remaining time for this QDeadlineTimer object to msecs milliseconds from now,...
static QDeadlineTimer addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcept Q_DECL_PURE_FUNCTION
Returns a QDeadlineTimer object whose deadline is extended from dt's deadline by nsecs nanoseconds.
void setPreciseRemainingTime(qint64 secs, qint64 nsecs=0, Qt::TimerType type=Qt::CoarseTimer) noexcept
Sets the remaining time for this QDeadlineTimer object to secs seconds plus nsecs nanoseconds from no...
void setTimerType(Qt::TimerType type)
Changes the timer type for this object to timerType.
qint64 deadline() const noexcept Q_DECL_PURE_FUNCTION
Returns the absolute time point for the deadline stored in QDeadlineTimer object, calculated in milli...
bool hasExpired() const noexcept
Returns true if this QDeadlineTimer object has expired, false if there remains time left.
constexpr bool isForever() const noexcept
Returns true if this QDeadlineTimer object never expires, false otherwise.
constexpr QDeadlineTimer() noexcept=default
qint64 remainingTimeNSecs() const noexcept
Returns the remaining time in this QDeadlineTimer object in nanoseconds.
qint64 remainingTime() const noexcept
Returns the remaining time in this QDeadlineTimer object in milliseconds.
Qt::TimerType timerType() const noexcept
Returns the timer type is active for this object.
qint64 deadlineNSecs() const noexcept Q_DECL_PURE_FUNCTION
Returns the absolute time point for the deadline stored in QDeadlineTimer object, calculated in nanos...
void setPreciseDeadline(qint64 secs, qint64 nsecs=0, Qt::TimerType type=Qt::CoarseTimer) noexcept
Sets the deadline for this QDeadlineTimer object to be secs seconds and nsecs nanoseconds since the r...
Combined button and popup list for selecting options.
constexpr const T & min(const T &a, const T &b)
QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs)
static qint64 add_saturate(qint64 t1, Duration1 dur, Durations... extra)
std::enable_if_t< std::is_unsigned_v< T >, bool > qAddOverflow(T v1, T v2, T *r)
std::enable_if_t< std::is_unsigned_v< T >, bool > qSubOverflow(T v1, T v2, T *r)
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
deadline setRemainingTime(250ms)