userver: engine::Deadline Class Reference
Loading...
Searching...
No Matches
engine::Deadline Class Referencefinal

#include <userver/engine/deadline.hpp>

Detailed Description

Internal representation of a deadline time point.

Definition at line 14 of file deadline.hpp.

Public Types

using Clock = std::chrono::steady_clock
 
using TimePoint = Clock::time_point
 
using Duration = TimePoint::duration
 

Public Member Functions

constexpr Deadline ()=default
 Creates an unreachable deadline.
 
constexpr bool IsReachable () const noexcept
 Returns whether the deadline can be reached.
 
bool IsReached () const noexcept
 Returns whether the deadline is reached.
 
bool IsSurelyReachedApprox () const noexcept
 
Duration TimeLeft () const noexcept
 Returns the duration of time left before the reachable deadline.
 
Duration TimeLeftApprox () const noexcept
 
constexpr TimePoint GetTimePoint () const noexcept
 
constexpr bool operator== (const Deadline &r) const noexcept
 
constexpr bool operator< (const Deadline &r) const noexcept
 

Static Public Member Functions

template<typename Rep , typename Period >
static Deadline FromDuration (const std::chrono::duration< Rep, Period > &duration) noexcept
 Converts duration to a Deadline.
 
static Deadline FromDuration (const Duration &duration) noexcept
 
template<typename Clock , typename Duration >
static Deadline FromTimePoint (const std::chrono::time_point< Clock, Duration > &time_point) noexcept
 Converts time point to a Deadline.
 
static constexpr Deadline Passed () noexcept
 A Deadline that is guaranteed to be IsReached.
 
template<typename Rep , typename Period >
static Duration ToDurationSaturating (const std::chrono::duration< Rep, Period > &from) noexcept
 Converts 'std::chrono::duration<>' to 'Deadline::Duration'.
 

Member Typedef Documentation

◆ Clock

using engine::Deadline::Clock = std::chrono::steady_clock

Definition at line 16 of file deadline.hpp.

◆ Duration

using engine::Deadline::Duration = TimePoint::duration

Definition at line 18 of file deadline.hpp.

◆ TimePoint

using engine::Deadline::TimePoint = Clock::time_point

Definition at line 17 of file deadline.hpp.

Member Function Documentation

◆ FromDuration() [1/2]

static Deadline engine::Deadline::FromDuration ( const Duration &  duration)
inlinestaticnoexcept

Definition at line 52 of file deadline.hpp.

◆ FromDuration() [2/2]

template<typename Rep , typename Period >
static Deadline engine::Deadline::FromDuration ( const std::chrono::duration< Rep, Period > &  duration)
inlinestaticnoexcept

Converts duration to a Deadline.

Definition at line 48 of file deadline.hpp.

◆ FromTimePoint()

template<typename Clock , typename Duration >
static Deadline engine::Deadline::FromTimePoint ( const std::chrono::time_point< Clock, Duration > &  time_point)
inlinestaticnoexcept

Converts time point to a Deadline.

Non-steady clocks may produce inaccurate Deadlines. Prefer using Deadline::FromDuration or std::chrono::steady_clock::time_point if possible.

Definition at line 65 of file deadline.hpp.

◆ GetTimePoint()

constexpr TimePoint engine::Deadline::GetTimePoint ( ) const
inlineconstexprnoexcept

Returns the native time point value. Returns TimePoint::max() for unreachable deadline and TimePoint::min() for Deadline::Passed()

Definition at line 44 of file deadline.hpp.

◆ IsReachable()

constexpr bool engine::Deadline::IsReachable ( ) const
inlineconstexprnoexcept

Returns whether the deadline can be reached.

Definition at line 24 of file deadline.hpp.

◆ IsSurelyReachedApprox()

bool engine::Deadline::IsSurelyReachedApprox ( ) const
noexcept

Returns whether the deadline is reached. Will report false-negatives, will never report false-positives.

◆ operator<()

constexpr bool engine::Deadline::operator< ( const Deadline r) const
inlineconstexprnoexcept

Definition at line 79 of file deadline.hpp.

◆ operator==()

constexpr bool engine::Deadline::operator== ( const Deadline r) const
inlineconstexprnoexcept

Definition at line 77 of file deadline.hpp.

◆ Passed()

static constexpr Deadline engine::Deadline::Passed ( )
inlinestaticconstexprnoexcept

A Deadline that is guaranteed to be IsReached.

Definition at line 75 of file deadline.hpp.

◆ TimeLeftApprox()

Duration engine::Deadline::TimeLeftApprox ( ) const
noexcept

Returns the approximate duration of time left before the reachable deadline. May be faster than TimeLeft.

See also
utils::datetime::SteadyCoarseClock

◆ ToDurationSaturating()

template<typename Rep , typename Period >
static Duration engine::Deadline::ToDurationSaturating ( const std::chrono::duration< Rep, Period > &  from)
inlinestaticnoexcept

Converts 'std::chrono::duration<>' to 'Deadline::Duration'.

Definition at line 87 of file deadline.hpp.


The documentation for this class was generated from the following file: