MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / wake_next_timer

Method wake_next_timer

crates/runtime/src/sim/time/mod.rs:68–82  ·  view source on GitHub ↗

Jump virtual time to the earliest outstanding timer and wake it. The executor calls this when there are no runnable tasks left. Instead of incrementing time in wall-clock steps, simulation time jumps directly to the minimum timer deadline. Returns `false` if there are no timers to wake.

(&self)

Source from the content-addressed store, hash-verified

66 /// directly to the minimum timer deadline. Returns `false` if there are no
67 /// timers to wake.
68 pub fn wake_next_timer(&self) -> bool {
69 let wakers = {
70 let mut state = self.inner.lock();
71 let Some(next_deadline) = state.timers.values().map(|timer| timer.deadline).min() else {
72 return false;
73 };
74 if next_deadline > state.now {
75 state.now = next_deadline;
76 }
77 state.take_due_wakers()
78 };
79 let woke = !wakers.is_empty();
80 wake_all(wakers);
81 woke
82 }
83
84 /// Register or refresh a timer entry for a sleeping future.
85 ///

Callers 1

block_onMethod · 0.80

Calls 6

wake_allFunction · 0.85
lockMethod · 0.80
take_due_wakersMethod · 0.80
mapMethod · 0.45
valuesMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected