vihaco_stdlib::clock
clock¶
vihaco_stdlib::clock
Reusable global-clock and timing vocabulary for vihaco runtimes.
GlobalClock is an ordered event queue. It owns modeled timeline state, but does not execute instructions, dispatch events, or know about the machine that owns it. A runtime can use the types in this module to build its own scheduling policy and root event loop.
classGlobalClock¶source
vihaco_stdlib::clock::GlobalClock
Bases: Default
Rust struct. A deterministic event queue ordered by global tick and insertion sequence.
pub struct GlobalClock<E>methodis_empty¶source
vihaco_stdlib::clock::GlobalClock::is_empty
methodnew¶source
vihaco_stdlib::clock::GlobalClock::new
methodnow¶source
vihaco_stdlib::clock::GlobalClock::now
methodpop_earliest¶source
vihaco_stdlib::clock::GlobalClock::pop_earliest
pub fn pop_earliest(&mut self) -> Option<(GlobalTick, E)>Returns
Option<(GlobalTick, E)>
Removes the earliest event and advances the current global tick to it.
sourcemethodschedule_after¶source
vihaco_stdlib::clock::GlobalClock::schedule_after
Signature
pub fn schedule_after(&mut self, after: GlobalDuration, event: E) -> Result<(), ClockFault>Parameters
| Name | Type | Description |
|---|---|---|
after | GlobalDuration | |
event | E |
Returns
Result<(), ClockFault>
Converts relative work into an absolute global tick.
sourcemethodschedule_at¶source
vihaco_stdlib::clock::GlobalClock::schedule_at
Signature
pub fn schedule_at(&mut self, tick: GlobalTick, event: E) -> Result<(), ClockFault>Parameters
| Name | Type | Description |
|---|---|---|
tick | GlobalTick | |
event | E |
Returns
Result<(), ClockFault>
Inserts owned scheduling work at an absolute global tick.
sourceclassGlobalDuration¶source
vihaco_stdlib::clock::GlobalDuration
Bases: Debug, Clone, Copy, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord
Rust struct. A distance between two positions on the modeled global timeline.
classGlobalTick¶source
vihaco_stdlib::clock::GlobalTick
Bases: Debug, Clone, Copy, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord
Rust struct. An absolute position on the modeled global timeline.
pub struct GlobalTickFields
| Name | Type | Description |
|---|---|---|
0 | u64 |
methodchecked_add¶source
vihaco_stdlib::clock::GlobalTick::checked_add
Signature
pub fn checked_add(self, duration: GlobalDuration) -> Result<Self, ClockFault>Parameters
| Name | Type | Description |
|---|---|---|
duration | GlobalDuration |
Returns
Result<Self, ClockFault>
classGlobalTicksPerLocalCycle¶source
vihaco_stdlib::clock::GlobalTicksPerLocalCycle
Bases: Debug, Clone, Copy, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord
Rust struct. The conversion ratio from local cycles to global ticks.
classLocalCycles¶source
vihaco_stdlib::clock::LocalCycles
Bases: Debug, Clone, Copy, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord
Rust struct. Work measured in the local clock domain of a component.
pub struct LocalCyclesFields
| Name | Type | Description |
|---|---|---|
0 | u64 |
methodchecked_add¶source
vihaco_stdlib::clock::LocalCycles::checked_add
pub fn checked_add(self, other: Self) -> Result<Self, ClockFault>Parameters
| Name | Type | Description |
|---|---|---|
other | Self |
Returns
Result<Self, ClockFault>
methodchecked_mul¶source
vihaco_stdlib::clock::LocalCycles::checked_mul
Signature
pub fn checked_mul(self, ratio: GlobalTicksPerLocalCycle) -> Result<GlobalDuration, ClockFault>Parameters
| Name | Type | Description |
|---|---|---|
ratio | GlobalTicksPerLocalCycle |
Returns
Result<GlobalDuration, ClockFault>
classSchedule¶source
vihaco_stdlib::clock::Schedule
Bases: Debug, StructuralPartialEq, PartialEq, Eq
Rust struct. Owned scheduling work returned by a clocked component.
classClockFault¶source
vihaco_stdlib::clock::ClockFault
Bases: Debug, StructuralPartialEq, PartialEq, Eq, Display, Error
Rust enum. Errors produced while validating or advancing a modeled clock.
pub enum ClockFaultVariants
| Name | Type | Description |
|---|---|---|
ZeroTickRatio | — | |
LocalCycleOverflow | — | |
DurationOverflow | — | |
GlobalTickOverflow | — | |
SequenceOverflow | — | |
SchedulingInPast | — |
classClockedComponent¶source
vihaco_stdlib::clock::ClockedComponent
Rust trait. Generic boundary for a component that participates in a global event loop.
pub trait ClockedComponent: SizedAssociated items
| Name | Type | Description |
|---|---|---|
Event | type Event | associated type |
Completion | type Completion | associated type |
Fault | type Fault | associated type |
methodnext_boundary_at¶source
vihaco_stdlib::clock::ClockedComponent::next_boundary_at
Signature
fn next_boundary_at(&self, global_tick: GlobalTick, ticks_per_local_cycle: GlobalTicksPerLocalCycle) -> Result<GlobalTick, <Self as >::Fault>Parameters
| Name | Type | Description |
|---|---|---|
global_tick | GlobalTick | |
ticks_per_local_cycle | GlobalTicksPerLocalCycle |
Returns
Result<GlobalTick, <Self as >::Fault>
methodresume¶source
vihaco_stdlib::clock::ClockedComponent::resume
Signature
fn resume(&mut self, completion: <Self as >::Completion, global_tick: GlobalTick, ticks_per_local_cycle: GlobalTicksPerLocalCycle) -> Result<Option<Schedule<<Self as >::Event>>, <Self as >::Fault>Parameters
| Name | Type | Description |
|---|---|---|
completion | <Self as >::Completion | |
global_tick | GlobalTick | |
ticks_per_local_cycle | GlobalTicksPerLocalCycle |
Returns
Result<Option<Schedule<<Self as >::Event>>, <Self as >::Fault>
methodstep_at¶source
vihaco_stdlib::clock::ClockedComponent::step_at
Signature
fn step_at(&mut self, global_tick: GlobalTick, ticks_per_local_cycle: GlobalTicksPerLocalCycle) -> Result<Option<Schedule<<Self as >::Event>>, <Self as >::Fault>Parameters
| Name | Type | Description |
|---|---|---|
global_tick | GlobalTick | |
ticks_per_local_cycle | GlobalTicksPerLocalCycle |
Returns
Result<Option<Schedule<<Self as >::Event>>, <Self as >::Fault>
classTimedInstruction¶source
vihaco_stdlib::clock::TimedInstruction
Rust trait. Runtime instructions provide the local duration of their operation.