Refactor ruin_app, add some README files, minor usability in reactivity

This commit is contained in:
2026-03-25 22:32:11 -04:00
parent 5f67c06083
commit 341d07d82f
28 changed files with 2782 additions and 2118 deletions

0
lib/runtime/README.md Normal file
View File

View File

@@ -29,7 +29,10 @@ pub(crate) mod trace_targets {
pub const DRIVER: &str = "ruin_runtime::driver";
pub const RUNTIME: &str = "ruin_runtime::runtime";
pub const SCHEDULER: &str = "ruin_runtime::scheduler";
#[cfg(debug_assertions)]
pub const TIMER: &str = "ruin_runtime::timer";
#[cfg(debug_assertions)]
pub const ASYNC: &str = "ruin_runtime::async";
}

View File

@@ -54,6 +54,12 @@ pub struct TimeoutHandle {
_local: Rc<()>,
}
impl TimeoutHandle {
pub fn clear(&self) {
clear_timeout(self);
}
}
#[derive(Clone)]
/// Handle returned by [`set_interval`].
pub struct IntervalHandle {
@@ -62,6 +68,12 @@ pub struct IntervalHandle {
_local: Rc<()>,
}
impl IntervalHandle {
pub fn clear(&self) {
clear_interval(self);
}
}
/// Handle returned by [`queue_future`].
///
/// Awaiting a join handle yields the output of the queued future.
@@ -72,9 +84,10 @@ pub struct JoinHandle<T> {
/// Future returned by [`yield_now`].
///
/// Awaiting this future will immediately yield control back to the runtime scheduler, allowing other queued microtasks
/// to run before the current task continues executing. Note that continuation of futures runs as a microtask, so this
/// to run before the current task continues executing. Note that continuations of futures run as microtasks, so this
/// can only yield to other microtasks and not to macrotasks (driver events such as file or network I/O, timers, or
/// channel messages).
/// channel messages). To yield to macrotasks, you must allow the flow of execution to return to the runtime event loop
/// and flush the full microtask queue, for example by awaiting a timer.
pub struct YieldNow {
yielded: bool,
}