Commit e15c378
committed
feat(timer): add the standard timer host module
Add the self-contained timer host-function module with
`timer::{at,every,pending_count,running_count}`, the `TimerBackend` contract,
`TimerConfig`/`TimerRegistration` admission limits, and the `TimerExtension`
composition/install entry point.
The module owns callback ownership transfer, the private callback VM, callback
state (Ready/Running/Waiting/Yielded/Complete/Cancelled), error isolation,
per-callback async bridges, and transactional registration rollback. The VM
core stays timer-free apart from the generic owned-value registry. Admission
limits travel with every registration and are MUST-enforce obligations on the
backend; `timer::pending_count` / `timer::running_count` are pure backend
queries and the module keeps no counters of its own.
The callback parameter is typed `fn(bool) -> null`: the callback observes the
`premature` flag and its return value is discarded, so the declared result is
the typed expression of "no result" -- this revision's public host catalogs
carry concrete schemas only.
Downstream adapter surface: `register_owned_timer` lets an embedding expose the
same contract under its own exact host name and schema -- it takes the owned
call, the callback argument index, and a checked `Duration` plus an optional
repeating `Duration`, and reuses the runtime lookup, callback type/provenance
checks, fresh isolated callback VM, admission limits, backend registration and
rollback of the standard adapters, so `OwnedTimerCallback::new` never needs to
become public. `installed_timer_counts` exposes the installed backend's
synchronous pending/running counts for thin adapter count functions. Both
helpers are name-independent and unit-independent; `timer::at` / `timer::every`
are millisecond adapters over the same path.
The builtin runtime composes the timer surface into the standard catalog, so a
compiled program resolves the imports and each call fails with the documented
installation error until backend state is installed.1 parent 1213739 commit e15c378
3 files changed
Lines changed: 1029 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
47 | 55 | | |
48 | 56 | | |
49 | 57 | | |
| |||
375 | 383 | | |
376 | 384 | | |
377 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
378 | 401 | | |
379 | 402 | | |
380 | 403 | | |
| |||
0 commit comments