2026-02-07 16:51:40 +00:00
|
|
|
use std::any::Any;
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
use std::collections::{HashMap, HashSet};
|
|
|
|
|
use std::hash::{BuildHasher, Hasher};
|
2026-02-06 11:25:37 +00:00
|
|
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
fix: mild refactor and test coverage (#37)
Extract the timer wheel and watch registry from the worker into a reusable std-extension crate, generalize the worker around a RuntimeExtension factory, and decompose the monolithic runtime test file into focused suites.
- crates/std: extract TimerWheel (deterministic tick-counted one-shot/interval timers) and WatchRegistry (target-to-watcher death-notification index) out of src/worker.rs into reusable modules
- crates/std: add Ctx extension traits (CtxMonitoring, CtxNaming, CtxWatching, CtxTimers) and Runtime extension traits (RuntimeNaming, RuntimeWatching, RuntimeGroups) wiring monitor/name/watch/timer/group support
- src/worker.rs: replace the hard-coded timer/watch fields with a generic RuntimeExtension factory and add route_to_pool_or_remote for message routing (local pool, then cross-worker address map, then external inboxes)
- tests: split the 4622-line tests/runtime_api.rs into focused suites (actor_lifecycle, message_delivery, runtime_stress, std_extension) plus a shared tests/common/mod.rs harness, and drop watch_api.rs
- benches/fuzz: add runtime_benchmarks and adjust the runtime fuzz target
- tools/docs: add fn_complexity.py and loc_analysis.py analysis scripts and refresh the runtime and worker-thread docs
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 15:00:53 +00:00
|
|
|
use std::sync::{Arc, OnceLock, RwLock};
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
use std::thread::Thread;
|
2026-02-06 11:25:37 +00:00
|
|
|
|
2026-02-07 16:51:40 +00:00
|
|
|
use crate::actor::{ActorAddress, AnyActor, Message};
|
|
|
|
|
use crate::channel::Sender;
|
|
|
|
|
use crate::config::RuntimeConfig;
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
use crate::stats::WorkerStats;
|
2026-02-07 16:51:40 +00:00
|
|
|
use crate::Error;
|
|
|
|
|
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
// ─── Identity Hasher for ActorAddress ───────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
/// Identity hasher for ActorAddress keys.
|
|
|
|
|
///
|
|
|
|
|
/// ActorAddress contains 32 cryptographically random bytes. The custom `Hash`
|
|
|
|
|
/// impl on ActorAddress writes only the first 8 bytes as a `u64`. This hasher
|
|
|
|
|
/// passes that u64 through as the hash value directly — no mixing, no SipHash.
|
|
|
|
|
///
|
|
|
|
|
/// This is safe because the input is already random (uniform distribution),
|
|
|
|
|
/// so additional mixing would be redundant.
|
|
|
|
|
pub struct AddrHasher(u64);
|
|
|
|
|
|
|
|
|
|
impl Hasher for AddrHasher {
|
|
|
|
|
#[inline]
|
|
|
|
|
fn finish(&self) -> u64 {
|
|
|
|
|
self.0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
fn write(&mut self, _bytes: &[u8]) {
|
|
|
|
|
// Unused — ActorAddress::hash calls write_u64 directly.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
fn write_u64(&mut self, i: u64) {
|
|
|
|
|
self.0 = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// BuildHasher for creating AddrHasher instances.
|
|
|
|
|
#[derive(Default, Clone)]
|
|
|
|
|
pub struct AddrBuildHasher;
|
|
|
|
|
|
|
|
|
|
impl BuildHasher for AddrBuildHasher {
|
|
|
|
|
type Hasher = AddrHasher;
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
fn build_hasher(&self) -> AddrHasher {
|
|
|
|
|
AddrHasher(0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// HashMap optimized for ActorAddress keys.
|
|
|
|
|
/// Uses identity hashing since ActorAddress bytes are already random.
|
|
|
|
|
pub type AddrMap<V> = HashMap<ActorAddress, V, AddrBuildHasher>;
|
|
|
|
|
|
|
|
|
|
/// HashSet optimized for ActorAddress keys.
|
|
|
|
|
pub type AddrSet = HashSet<ActorAddress, AddrBuildHasher>;
|
|
|
|
|
|
2026-02-07 16:51:40 +00:00
|
|
|
// ─── Address Map Types ───────────────────────────────────────────────────────
|
2026-02-06 11:25:37 +00:00
|
|
|
|
|
|
|
|
/// Identifies a worker thread.
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
|
|
|
|
pub(crate) struct WorkerId(pub(crate) usize);
|
|
|
|
|
|
|
|
|
|
impl WorkerId {
|
|
|
|
|
pub fn as_usize(self) -> usize {
|
|
|
|
|
self.0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Maps actor addresses to the worker that owns them.
|
|
|
|
|
///
|
|
|
|
|
/// `RwLock<HashMap>` — zero contention for parallel reads, write-rare (only on spawn).
|
|
|
|
|
pub(crate) struct AddressMap {
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
inner: RwLock<AddrMap<WorkerId>>,
|
2026-02-06 11:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl AddressMap {
|
|
|
|
|
pub fn with_capacity(cap: usize) -> Self {
|
|
|
|
|
Self {
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
inner: RwLock::new(HashMap::with_capacity_and_hasher(cap, AddrBuildHasher)),
|
2026-02-06 11:25:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn insert(&self, addr: ActorAddress, worker: WorkerId) {
|
|
|
|
|
self.inner.write().unwrap().insert(addr, worker);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn lookup(&self, addr: &ActorAddress) -> Option<WorkerId> {
|
|
|
|
|
self.inner.read().unwrap().get(addr).copied()
|
|
|
|
|
}
|
|
|
|
|
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
/// Remove an actor address from the map (e.g., after permanent poisoning).
|
|
|
|
|
pub fn remove(&self, addr: &ActorAddress) {
|
|
|
|
|
self.inner.write().unwrap().remove(addr);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-06 13:35:46 +00:00
|
|
|
/// Returns a snapshot of all (address, worker) pairs.
|
|
|
|
|
pub fn snapshot(&self) -> Vec<(ActorAddress, WorkerId)> {
|
|
|
|
|
self.inner
|
|
|
|
|
.read()
|
|
|
|
|
.unwrap()
|
|
|
|
|
.iter()
|
|
|
|
|
.map(|(addr, wid)| (*addr, *wid))
|
|
|
|
|
.collect()
|
|
|
|
|
}
|
2026-02-06 11:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
/// Load-aware actor placement strategy.
|
|
|
|
|
///
|
|
|
|
|
/// Picks the worker with the lowest load score (actor count + mailbox depth).
|
|
|
|
|
/// When all workers have equal load (e.g., before any ticks), falls back to
|
|
|
|
|
/// round-robin via a rotating start position for the scan.
|
2026-02-06 11:25:37 +00:00
|
|
|
pub(crate) struct Placement {
|
|
|
|
|
next: AtomicUsize,
|
|
|
|
|
num_workers: usize,
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
worker_stats: Vec<Arc<WorkerStats>>,
|
2026-02-06 11:25:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Placement {
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
pub fn new(num_workers: usize, worker_stats: Vec<Arc<WorkerStats>>) -> Self {
|
2026-02-06 11:25:37 +00:00
|
|
|
Self {
|
|
|
|
|
next: AtomicUsize::new(0),
|
|
|
|
|
num_workers,
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
worker_stats,
|
2026-02-06 11:25:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn next_worker(&self) -> WorkerId {
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
let n = self.num_workers;
|
|
|
|
|
if n == 1 {
|
|
|
|
|
return WorkerId(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Rotate the scan start for round-robin tie-breaking
|
|
|
|
|
let rr = self.next.fetch_add(1, Ordering::Relaxed);
|
|
|
|
|
|
|
|
|
|
let mut best_id = rr % n;
|
|
|
|
|
let mut best_score = usize::MAX;
|
|
|
|
|
|
|
|
|
|
for offset in 0..n {
|
|
|
|
|
let i = (rr + offset) % n;
|
|
|
|
|
let actors = self.worker_stats[i].num_actors.load(Ordering::Relaxed);
|
|
|
|
|
let depth = self.worker_stats[i].total_mailbox_depth.load(Ordering::Relaxed);
|
|
|
|
|
let score = actors + depth;
|
|
|
|
|
if score < best_score {
|
|
|
|
|
best_score = score;
|
|
|
|
|
best_id = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WorkerId(best_id)
|
2026-02-06 11:25:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-07 16:51:40 +00:00
|
|
|
// ─── Delivery Types ──────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
/// A type-erased message envelope for cross-worker delivery.
|
|
|
|
|
///
|
|
|
|
|
/// Uses `Box` (no atomic refcount) and move semantics (no clone).
|
|
|
|
|
pub(crate) struct Envelope {
|
|
|
|
|
dest: ActorAddress,
|
|
|
|
|
payload: Box<dyn Any + Send>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Envelope {
|
|
|
|
|
pub fn new(dest: ActorAddress, payload: Box<dyn Any + Send>) -> Self {
|
|
|
|
|
Self { dest, payload }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn dest(&self) -> ActorAddress {
|
|
|
|
|
self.dest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn into_payload(self) -> Box<dyn Any + Send> {
|
|
|
|
|
self.payload
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Type-erased sender for external inboxes.
|
|
|
|
|
pub(crate) trait SenderT: Send + Sync {
|
|
|
|
|
fn try_send_any(&self, msg: Box<dyn Any + Send>);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<M: Message> SenderT for Sender<M> {
|
|
|
|
|
fn try_send_any(&self, msg: Box<dyn Any + Send>) {
|
|
|
|
|
if let Ok(typed) = msg.downcast::<M>() {
|
2026-02-10 07:35:58 +00:00
|
|
|
Sender::send(self, *typed);
|
2026-02-07 16:51:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Registry of external inboxes — replaces the Router's role for non-actor receivers.
|
|
|
|
|
pub(crate) struct InboxRegistry {
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
senders: RwLock<AddrMap<Arc<dyn SenderT>>>,
|
2026-02-07 16:51:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl InboxRegistry {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self {
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
senders: RwLock::new(HashMap::with_hasher(AddrBuildHasher)),
|
2026-02-07 16:51:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn register(&self, addr: ActorAddress, sender: Arc<dyn SenderT>) {
|
|
|
|
|
self.senders.write().unwrap().insert(addr, sender);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-09 19:05:37 +00:00
|
|
|
/// Check if an address is registered without consuming a message.
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
#[cfg(feature = "transport")]
|
2026-02-09 19:05:37 +00:00
|
|
|
pub fn contains(&self, addr: &ActorAddress) -> bool {
|
|
|
|
|
self.senders.read().unwrap().contains_key(addr)
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-07 16:51:40 +00:00
|
|
|
pub fn try_deliver(
|
|
|
|
|
&self,
|
|
|
|
|
addr: ActorAddress,
|
|
|
|
|
msg: Box<dyn Any + Send>,
|
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
|
let senders = self.senders.read().unwrap();
|
|
|
|
|
if let Some(sender) = senders.get(&addr) {
|
|
|
|
|
sender.try_send_any(msg);
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
Err(Error::from("Address not found"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Shared state passed to tick_once — single thin pointer avoids register spill.
|
|
|
|
|
pub(crate) struct TickContext<'a> {
|
|
|
|
|
pub(crate) address_map: &'a AddressMap,
|
|
|
|
|
pub(crate) transfer_txs: &'a [Sender<Envelope>],
|
|
|
|
|
pub(crate) spawn_txs: &'a [Sender<(ActorAddress, Box<dyn AnyActor>)>],
|
|
|
|
|
pub(crate) placement: &'a Placement,
|
|
|
|
|
pub(crate) inbox_registry: &'a InboxRegistry,
|
|
|
|
|
pub(crate) config: &'a RuntimeConfig,
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
pub(crate) extension: Option<&'a dyn crate::extension::RuntimeExtension>,
|
2026-02-11 15:23:26 +00:00
|
|
|
pub(crate) stats_hook: Option<&'a dyn crate::stats::StatsHook>,
|
feat(std): add supervision, router, and registries
Adds the std crate on top of the core runtime: Supervisor with RestartPolicy
(Permanent/Transient/Temporary) and SupervisorStrategy (OneForOne/OneForAll/
RestForOne), Router with RoutingStrategy, name/monitor/group registries, StdExtension,
and Ctx/Runtime extension traits. Also extends core (worker, actor, delivery identity
hashing, config, stats), adds a fuzz target, a proptest suite, expands runtime_api
tests, and adds cfuzz cycle notes + benchmarks.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-13 07:11:24 +00:00
|
|
|
/// Thread handles for waking parked workers on cross-worker sends.
|
|
|
|
|
pub(crate) worker_threads: &'a [OnceLock<Thread>],
|
2026-02-09 19:05:37 +00:00
|
|
|
#[cfg(feature = "transport")]
|
|
|
|
|
pub(crate) codec_registry: Option<&'a crate::transport::CodecRegistry>,
|
|
|
|
|
#[cfg(feature = "transport")]
|
|
|
|
|
pub(crate) transport_router: Option<&'a crate::transport::TransportRouter>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'a> TickContext<'a> {
|
|
|
|
|
/// Route a message whose destination is not in the local address map.
|
|
|
|
|
/// Tries inbox registry, then remote transport, then falls back to inbox error.
|
|
|
|
|
pub(crate) fn route_nonlocal(
|
|
|
|
|
&self,
|
|
|
|
|
addr: ActorAddress,
|
|
|
|
|
msg: Box<dyn Any + Send>,
|
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
|
#[cfg(feature = "transport")]
|
|
|
|
|
{
|
|
|
|
|
if self.inbox_registry.contains(&addr) {
|
|
|
|
|
return self.inbox_registry.try_deliver(addr, msg);
|
|
|
|
|
}
|
|
|
|
|
if let (Some(cr), Some(tr)) = (self.codec_registry, self.transport_router) {
|
|
|
|
|
return crate::transport::send_via_transport(addr, msg, cr, tr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self.inbox_registry.try_deliver(addr, msg)
|
|
|
|
|
}
|
2026-02-07 16:51:40 +00:00
|
|
|
}
|