载入中...
搜索中...
未找到
eve::SimulationClock类 参考

Owner-thread fixed-step scheduler driven by an injected time source. 更多...

#include <Time.h>

Public 成员函数

 SimulationClock (ITimeSource &source, Duration fixedStep=Duration::fromNanoseconds(16666667))
 Construct a fixed-step clock without reading the source.
 
Result< std::vector< SimulationStep > > sample ()
 Read the source and emit deterministic steps for one frame.
 
Result< std::vector< SimulationStep > > advance (Duration realDelta)
 Advance from supplied monotonic elapsed duration without reading a clock.
 
Result< void > setFixedStep (Duration fixedStep)
 Set the positive fixed-step duration; accumulated time is preserved.
 
Result< void > setRate (double rate)
 Set a finite non-negative simulation rate (1 is normal speed).
 
void setPaused (bool paused) noexcept
 Pause or resume simulation accumulation.
 
void reset (SimulationTick tick=SimulationTick::zero()) noexcept
 Reset deterministic state to a supplied tick without reading a clock.
 
SimulationTick currentTick () const noexcept
 Current deterministic simulation tick.
 
FrameIndex frameIndex () const noexcept
 Current presentation frame ordinal.
 
Duration fixedStep () const noexcept
 Fixed duration of emitted simulation steps.
 
double rate () const noexcept
 Current slow-motion rate.
 
bool paused () const noexcept
 Whether simulation accumulation is paused.
 
Duration lastFrameDelta () const noexcept
 Real source duration observed during the last frame.
 

详细描述

Owner-thread fixed-step scheduler driven by an injected time source.

sample() reads only monotonic time. advance() is the replay/server path and accepts a supplied Duration, so tests and deterministic replays do not need a real clock. Paused clocks do not accumulate catch-up time. A slow rate scales accumulated simulation time while emitted steps remain fixed. The scheduler is not thread-safe; one owner thread must serialize all calls.

在文件 Time.h 第 201 行定义.

构造及析构函数说明

◆ SimulationClock()

eve::SimulationClock::SimulationClock ( ITimeSource &  source,
Duration  fixedStep = Duration::fromNanoseconds(16666667) 
)
explicit

Construct a fixed-step clock without reading the source.

参数
sourceBorrowed source; it must outlive this clock.
fixedStepPositive fixed simulation duration.

在文件 Time.cpp 第 65 行定义.

引用了 EV_ASSERT, eve::Duration::fromNanoseconds() , 以及 eve::Duration::nanoseconds().

成员函数说明

◆ advance()

Result< std::vector< SimulationStep > > eve::SimulationClock::advance ( Duration  realDelta)

Advance from supplied monotonic elapsed duration without reading a clock.

参数
realDeltaNon-negative elapsed frame duration.
返回
Fixed steps; failure leaves scheduler state unchanged.

在文件 Time.cpp 第 84 行定义.

引用了 eve::Diagnostic::error(), eve::detail::StrongUint64< Tag >::incremented(), eve::InvariantViolation, eve::Duration::nanoseconds(), eve::Duration::scaled(), steps, eve::Duration::tryAdd() , 以及 eve::detail::StrongUint64< Tag >::value().

被这些函数引用 sample().

◆ currentTick()

SimulationTick eve::SimulationClock::currentTick ( ) const
inlinenoexcept

Current deterministic simulation tick.

在文件 Time.h 第 231 行定义.

◆ fixedStep()

Duration eve::SimulationClock::fixedStep ( ) const
inlinenoexcept

Fixed duration of emitted simulation steps.

在文件 Time.h 第 235 行定义.

被这些函数引用 setFixedStep().

◆ frameIndex()

FrameIndex eve::SimulationClock::frameIndex ( ) const
inlinenoexcept

Current presentation frame ordinal.

在文件 Time.h 第 233 行定义.

◆ lastFrameDelta()

Duration eve::SimulationClock::lastFrameDelta ( ) const
inlinenoexcept

Real source duration observed during the last frame.

在文件 Time.h 第 241 行定义.

◆ paused()

bool eve::SimulationClock::paused ( ) const
inlinenoexcept

Whether simulation accumulation is paused.

在文件 Time.h 第 239 行定义.

◆ rate()

double eve::SimulationClock::rate ( ) const
inlinenoexcept

Current slow-motion rate.

在文件 Time.h 第 237 行定义.

被这些函数引用 setRate().

◆ reset()

void eve::SimulationClock::reset ( SimulationTick  tick = SimulationTick::zero())
noexcept

Reset deterministic state to a supplied tick without reading a clock.

在文件 Time.cpp 第 159 行定义.

引用了 tick, eve::detail::StrongUint64< detail::FrameIndexTag >::zero() , 以及 eve::Duration::zero().

◆ sample()

Result< std::vector< SimulationStep > > eve::SimulationClock::sample ( )

Read the source and emit deterministic steps for one frame.

在文件 Time.cpp 第 141 行定义.

引用了 advance(), first, eve::ITimeSource::monotonicNow(), eve::MonotonicTimestamp::since() , 以及 eve::Duration::zero().

◆ setFixedStep()

Result< void > eve::SimulationClock::setFixedStep ( Duration  fixedStep)

Set the positive fixed-step duration; accumulated time is preserved.

在文件 Time.cpp 第 70 行定义.

引用了 eve::Result< T >::failure(), fixedStep(), eve::Duration::nanoseconds() , 以及 eve::Result< T >::success().

◆ setPaused()

void eve::SimulationClock::setPaused ( bool  paused)
inlinenoexcept

Pause or resume simulation accumulation.

在文件 Time.h 第 225 行定义.

◆ setRate()

Result< void > eve::SimulationClock::setRate ( double  rate)

Set a finite non-negative simulation rate (1 is normal speed).

在文件 Time.cpp 第 77 行定义.

引用了 eve::Result< T >::failure(), rate() , 以及 eve::Result< T >::success().


该类的文档由以下文件生成: