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.
构造及析构函数说明
◆ SimulationClock()
|
explicit |
Construct a fixed-step clock without reading the source.
- 参数
-
source Borrowed source; it must outlive this clock. fixedStep Positive fixed simulation duration.
引用了 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.
- 参数
-
realDelta Non-negative elapsed frame duration.
- 返回
- Fixed steps; failure leaves scheduler state unchanged.
引用了 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()
|
inlinenoexcept |
◆ fixedStep()
|
inlinenoexcept |
◆ frameIndex()
|
inlinenoexcept |
◆ lastFrameDelta()
|
inlinenoexcept |
◆ paused()
|
inlinenoexcept |
◆ rate()
|
inlinenoexcept |
◆ reset()
|
noexcept |
Reset deterministic state to a supplied tick without reading a clock.
引用了 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.
引用了 advance(), first, eve::ITimeSource::monotonicNow(), eve::MonotonicTimestamp::since() , 以及 eve::Duration::zero().
◆ setFixedStep()
Set the positive fixed-step duration; accumulated time is preserved.
引用了 eve::Result< T >::failure(), fixedStep(), eve::Duration::nanoseconds() , 以及 eve::Result< T >::success().
◆ setPaused()
|
inlinenoexcept |
◆ setRate()
| Result< void > eve::SimulationClock::setRate | ( | double | rate | ) |
Set a finite non-negative simulation rate (1 is normal speed).
引用了 eve::Result< T >::failure(), rate() , 以及 eve::Result< T >::success().
该类的文档由以下文件生成: