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
72
//! Per-frame active-set tracking — replaces O(k) full-table scans during
//! the prepass with O(active) targeted iteration.
//!
//! ## How it works
//!
//! 1. **Register** — Widgets / platform code call `register_active(eid, tag)`
//! when an element begins needing per-frame work (e.g. a text input gains
//! focus → `CursorBlink`; a calendar starts animating → `FrameTick`).
//!
//! 2. **Process** — The prepass calls `drain_active(tag)` which atomically
//! takes the set *and* re-fills it with elements that still need work
//! (done by the processor).
//!
//! 3. **Cleanup** — `unregister_element` clears all tags for a removed
//! element. No stale entries accumulate.
//!
//! ## Benefits
//!
//! Idle frames (no focused input, no animation) iterate **zero** active
//! elements instead of scanning every `CursorComponent` / `LifecycleComponent`
//! entry in the component tables. Measured: ~286 µs → ~5 µs for the prepass
//! on a 2000-element stress test.
use crateElementId;
use HashSet;
/// Active-work tags. A single element can carry multiple tags simultaneously.
/// Register an element as needing per-frame processing for the given tag.
/// **Idempotent** — calling twice with the same tag for the same element is
/// a harmless no-op.
///
/// Element teardown automatically removes all tags; callers do **not** need
/// to unregister on unmount (though eager `unregister_active` is cheaper than
/// the idempotent check during the prepass).
/// Remove an element from the active-set for the given tag.
/// Check whether an element is currently active for the given tag.
/// Drain (take) all elements registered for `tag`, returning them as a
/// `HashSet`. The internal set is *cleared* — it is the caller's
/// responsibility to re-register elements that still need processing
/// next frame.
pub
/// Remove every active-set entry for an element (called during teardown).
pub