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)) {
270 }
else if (msecs == 0) {
272 t1 = std::numeric_limits<qint64>::min();
274 *
this = current(timerType);
275 milliseconds ms(msecs);
306 }
else if (secs == 0 && nsecs == 0) {
308 t1 = std::numeric_limits<qint64>::min();
310 *
this = current(timerType);
362 if (
t1 == std::numeric_limits<qint64>::min())
413 return ceil<milliseconds>(nsecs).count();
428 qint64 raw = rawRemainingTimeNSecs();
429 return raw < 0 ? 0 : raw;
438qint64 QDeadlineTimer::rawRemainingTimeNSecs() const noexcept
440 if (
t1 == std::numeric_limits<qint64>::min())
473 return TimeReference::Max;
474 if (
t1 == TimeReference::Min)
478 return duration_cast<milliseconds>(
ns).count();
505 return TimeReference::Max;
525 if (msecs == TimeReference::Max) {
582 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.
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...
constexpr QDeadlineTimer(Qt::TimerType type_=Qt::CoarseTimer) noexcept
Constructs an expired QDeadlineTimer object.
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)