1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! The thread the derivation runs on (DESIGN §7.2, bl-ee0a).
//!
//! yog's frame thread does two things: render the latest completed
//! [`Snapshot`](super::super::Snapshot) and capture input. Everything else — the
//! watchers, the dirty-root routing, both sweeps, every re-derivation, the ball
//! and ops fetches, the liveness probes — is [`Deriver::step`], and this is
//! where it is driven.
//!
//! The shell is deliberately three lines of loop. All the logic is in
//! [`Deriver`], which is a plain value over an injected clock, so every branch
//! is exercised by calling `step()` by hand — no thread, no sleeps, no
//! timing-dependent assertions. What is left here is the one thing a test
//! cannot fake, and it gets one test that runs the real thread.
//!
//! **The frame never waits on this.** The only shared state is
//! [`crate::state`]'s two hand-offs, each locked for a single pointer move; a
//! pass that takes ten seconds delays the *next snapshot*, never a frame.
//! Correctness does not ride on the poll interval either — [`WORKER_POLL`] is a
//! latency knob, the sweeps are the correctness floor (§7.2).
use Deriver;
use Arc;
use ;
use JoinHandle;
use Duration;
/// How often the worker looks for work. Short enough that a disk change
/// surfaces well inside a frame's own budget, and cheap when idle: an empty
/// pass is a drain of two empty maps and two deadline comparisons.
const WORKER_POLL: Duration = from_millis;
/// The derivation thread. Owns its join handle and a stop flag; [`Drop`]
/// signals stop, unparks, and joins for a clean shutdown — the same shape the
/// watch bridge had before it folded into this one thread (§7.2).