task_local context over context objects

- interner impls logically separate from API in orchid-base (default host interner still in base for testing)
- error reporting, logging, and a variety of other features passed down via context in extension, not yet in host to maintain library-ish profile, should consider options
- no global spawn mechanic, the host has a spawn function but extensions only get a stash for enqueuing async work in sync callbacks which is then explicitly, manually, and with strict order popped and awaited
- still deadlocks nondeterministically for some ungodly reason
This commit is contained in:
2026-01-01 14:54:29 +00:00
parent 06debb3636
commit 32d6237dc5
92 changed files with 2507 additions and 2223 deletions

View File

@@ -4,6 +4,7 @@ use std::io::{Write, stderr};
pub use api::LogStrategy;
use itertools::Itertools;
use task_local::task_local;
use crate::api;
@@ -34,3 +35,13 @@ impl Logger {
}
}
}
task_local! {
static LOGGER: Logger;
}
pub async fn with_logger<F: Future>(logger: Logger, fut: F) -> F::Output {
LOGGER.scope(logger, fut).await
}
pub fn logger() -> Logger { LOGGER.try_with(|l| l.clone()).expect("Logger not set!") }