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 16 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 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 > &incoming_duration) noexcept
 Converts duration to a Deadline.
 
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.
 

Member Typedef Documentation

◆ Clock

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

Definition at line 18 of file deadline.hpp.

◆ Duration

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

Definition at line 20 of file deadline.hpp.

◆ TimePoint

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

Definition at line 19 of file deadline.hpp.

Member Function Documentation

◆ FromDuration()

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

Converts duration to a Deadline.

Examples
samples/grpc_service/grpc_service.cpp.

Definition at line 45 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 88 of file deadline.hpp.

◆ IsReachable()

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

Returns whether the deadline can be reached.

Definition at line 26 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 107 of file deadline.hpp.

◆ operator==()

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

Definition at line 103 of file deadline.hpp.

◆ Passed()

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

A Deadline that is guaranteed to be IsReached.

Definition at line 101 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

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