Skip to main content

incular_runtime/
lib.rs

1//! Controlled BUILD → LAYOUT → PAINT coordination and local reactive state.
2
3mod application;
4mod application_activations;
5mod application_shell;
6mod application_types;
7mod context;
8mod environment;
9mod file_dialogs;
10mod frame;
11mod global_shortcuts;
12mod profiling;
13mod reactive;
14mod request_admission;
15mod request_channel;
16mod request_registry;
17mod restoration;
18mod route_focus;
19mod route_outlet;
20mod route_tasks;
21mod simulation;
22mod tasks;
23mod transient_presentation;
24mod undo;
25mod window_commands;
26mod window_state;
27
28pub use application::{Application, PERFORMANCE_OVERLAY_KEY};
29pub use application_activations::{
30    ActivationRouteBridge, ApplicationActivationListener, ApplicationActivationService,
31    ApplicationActivationSubscription,
32};
33pub use application_shell::{
34    ApplicationShellRequestId, ApplicationShellService, MemoryApplicationShellAdapter,
35    NativeApplicationShellApplyResult, NativeApplicationShellCompletion,
36    NativeApplicationShellEvent, NativeApplicationShellOperation, NativeApplicationShellRequest,
37    NotificationHandle, TrayItemHandle,
38};
39pub use application_types::{
40    ApplicationLifecycle, LastWindowPolicy, LifecycleTransition, RestorableWindowFactory,
41    RuntimeErrorReport, WindowError, WindowRestorationId,
42};
43pub use context::BuildContext;
44#[cfg(feature = "devtools")]
45pub use environment::devtools_registry;
46pub use environment::{EditableSignalKind, Signal, SignalRegistration};
47pub use file_dialogs::{
48    FileDialogCompletionStatus, FileDialogRequest, FileDialogService, MemoryFileDialogAdapter,
49    NativeFileDialogCompletion, NativeFileDialogRequest,
50};
51pub use frame::{EditingDiagnostics, EventTarget, FocusDiagnostics, FrameStats, Runtime};
52pub use global_shortcuts::{
53    GlobalShortcutCompletionStatus, GlobalShortcutRegistration, GlobalShortcutRegistrationRequest,
54    GlobalShortcutRequestId, GlobalShortcutService, GlobalShortcutUnregistrationRequest,
55    MemoryGlobalShortcutAdapter, NativeGlobalShortcutCompletion, NativeGlobalShortcutOperation,
56    NativeGlobalShortcutRequest,
57};
58pub use incular_accessibility::AccessibilityDiagnostics;
59#[cfg(feature = "hot-reload")]
60pub use incular_core::hot_reload::{HotPatch, HotPatchError, aslr_reference};
61pub use profiling::{
62    AccessibilitySnapshot, BudgetStatistics, FrameHistory, FrameRecord, FrameStatistics,
63    FrameTimings, FrameWork, GpuResourceSummary, GpuSample, PerformanceHub, PerformanceProfiler,
64    PerformanceSnapshot, ProfilerMode, RenderFrameMetrics, SchedulerCounters, TextCacheSnapshot,
65    WidgetWorkSnapshot, WindowPerformance,
66};
67pub use reactive::{Action, ActionDispatchError, ActionError, ActionState, Effect, Memo};
68pub use restoration::{
69    ClaimedRestorationScope, DEFAULT_RESTORATION_DEBOUNCE, DEFAULT_RESTORATION_SNAPSHOT_LIMIT,
70    FRAMEWORK_RESTORATION_FORMAT_VERSION, FileRestorationStore, InMemoryRestorationStore,
71    MAX_RESTORATION_SAVE_RETRIES, RESTORATION_RETRY_BACKOFF, Restorable, RestorationConfig,
72    RestorationDiagnostics, RestorationHandle, RestorationMigration, RestorationStore,
73    RestorationStoreError,
74};
75pub use route_focus::{RouteFocusOwner, RouteFocusState};
76pub use route_outlet::{OutletAttachError, OutletError, OutletId, OutletPlacement, RouteOutlet};
77pub use route_tasks::RouteTaskBinding;
78pub use simulation::{Screenshot, Simulation, SimulationError};
79pub use tasks::{
80    AsyncState, AsyncValue, RuntimeDiagnostics, RuntimeSpawner, RuntimeWake, Task, TaskFailure,
81    TaskHandle, TaskScope, TokioHandle, UiDispatcher,
82};
83pub use transient_presentation::{
84    ResolvedTransientPresentation, TransientFallbackReason, TransientPresentationResolution,
85};
86pub use undo::{UndoHistoryController, UndoHistoryState};
87pub use window_commands::{
88    NativeOperationCompletionStatus, NativeOperationRequest, NativeWindowCommand,
89    WindowCommandEnqueueError, WindowHandle, WindowOpener, WindowPlacementError,
90};
91pub use window_state::{ApplicationDiagnostics, WindowDiagnostics};
92
93// Compatibility imports for the existing implementation submodules. These
94// remain private to the facade while preserving their original super:: paths.
95pub(crate) use environment::{
96    BUILD_SCOPE, BuildScope, Dependency, NEXT_REACTIVE_NODE, ReactiveNode, ReactiveNodeId,
97    ReactiveQueue, ReactiveRootId, TrackedDependency,
98};
99pub(crate) use frame::diagnostic_input_trigger;
100
101/// Process-wide scheduler/reactivity counters. Relaxed atomics on the UI
102/// thread cost a single increment per event and never allocate.
103mod scheduler_counters {
104    use std::sync::atomic::{AtomicU64, Ordering};
105    pub static SIGNAL_READS: AtomicU64 = AtomicU64::new(0);
106    pub static SIGNAL_WRITES: AtomicU64 = AtomicU64::new(0);
107    pub static DEPENDENTS_ENQUEUED: AtomicU64 = AtomicU64::new(0);
108    pub static RUNTIME_WAKES: AtomicU64 = AtomicU64::new(0);
109    pub static REDRAW_REQUESTS: AtomicU64 = AtomicU64::new(0);
110    pub static FRAMES_STARTED: AtomicU64 = AtomicU64::new(0);
111    pub static FRAMES_PRESENTED: AtomicU64 = AtomicU64::new(0);
112    pub static FRAMES_SKIPPED: AtomicU64 = AtomicU64::new(0);
113    #[must_use]
114    pub fn load(counter: &AtomicU64) -> u64 {
115        counter.load(Ordering::Relaxed)
116    }
117}
118
119#[must_use]
120pub fn scheduler_counters() -> SchedulerCounters {
121    SchedulerCounters {
122        signal_reads: scheduler_counters::load(&scheduler_counters::SIGNAL_READS),
123        signal_writes: scheduler_counters::load(&scheduler_counters::SIGNAL_WRITES),
124        dependents_enqueued: scheduler_counters::load(&scheduler_counters::DEPENDENTS_ENQUEUED),
125        runtime_wakes: scheduler_counters::load(&scheduler_counters::RUNTIME_WAKES),
126        redraw_requests: scheduler_counters::load(&scheduler_counters::REDRAW_REQUESTS),
127        frames_started: scheduler_counters::load(&scheduler_counters::FRAMES_STARTED),
128        frames_presented: scheduler_counters::load(&scheduler_counters::FRAMES_PRESENTED),
129        frames_skipped: scheduler_counters::load(&scheduler_counters::FRAMES_SKIPPED),
130    }
131}