2026-01-25 13:38:34 +00:00
|
|
|
pub mod actor;
|
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 mod extension;
|
2026-06-06 17:53:25 +00:00
|
|
|
pub mod process_observer;
|
2026-02-06 11:25:37 +00:00
|
|
|
pub mod worker;
|
2026-01-23 05:00:57 +00:00
|
|
|
|
2026-06-06 17:53:25 +00:00
|
|
|
pub use process_observer::ProcessOutputObserver;
|
|
|
|
|
|
2026-02-20 17:34:43 +00:00
|
|
|
// Re-export well-known environment key types for convenient access.
|
2026-06-23 15:42:28 +00:00
|
|
|
pub use actor::{CapabilitySet, ExitValue, LogicalName, ServiceBinding, SpawnTimestamp};
|
2026-02-20 17:34:43 +00:00
|
|
|
|
2026-02-06 11:25:37 +00:00
|
|
|
pub(crate) mod channel;
|
2026-01-25 13:38:34 +00:00
|
|
|
pub(crate) mod error;
|
|
|
|
|
pub use error::Error;
|
2026-01-23 05:00:57 +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
|
|
|
// Re-export identity hashing types for ActorAddress-keyed collections.
|
|
|
|
|
pub use delivery::{AddrBuildHasher, AddrMap, AddrSet};
|
2026-02-06 11:25:37 +00:00
|
|
|
|
|
|
|
|
pub mod config;
|
2026-02-07 16:51:40 +00:00
|
|
|
pub(crate) mod delivery;
|
|
|
|
|
pub mod stats;
|
2026-02-06 11:25:37 +00:00
|
|
|
|
2026-01-25 13:38:34 +00:00
|
|
|
pub mod runtime;
|
2025-11-25 00:39:17 +00:00
|
|
|
|
2026-02-24 09:12:28 +00:00
|
|
|
#[cfg(feature = "std")]
|
|
|
|
|
pub mod std;
|
|
|
|
|
|
2026-02-13 13:27:34 +00:00
|
|
|
// Platform-aware Instant: web_time on wasm, std::time on native.
|
|
|
|
|
// web_time is a no-op re-export of std::time::Instant on non-wasm targets.
|
|
|
|
|
#[cfg(not(feature = "wasm"))]
|
2026-02-24 09:12:28 +00:00
|
|
|
pub(crate) use ::std::time::Instant;
|
2026-06-23 15:42:28 +00:00
|
|
|
#[cfg(feature = "wasm")]
|
|
|
|
|
pub(crate) use web_time::Instant;
|
2026-02-13 13:27:34 +00:00
|
|
|
|
2026-01-23 05:00:57 +00:00
|
|
|
#[cfg(feature = "getrandom")]
|
2026-01-25 13:38:34 +00:00
|
|
|
pub(crate) fn get_random(buf: &mut [u8]) {
|
2026-01-23 05:00:57 +00:00
|
|
|
getrandom::getrandom(buf).unwrap()
|
|
|
|
|
}
|
2025-11-25 00:39:17 +00:00
|
|
|
|
refactor: repack external bindings into their own crates (#19)
Split the monolithic crate into a Cargo workspace with the Python and Wasm bindings as separate member crates.
- Cargo.toml: declare a `[workspace]` with members `.`/`crates/swactor-python`/`crates/swactor-wasm`, remove the `python` feature and pyo3 dependency, and change root crate-type from `["cdylib","rlib"]` to `["rlib"]`
- crates/swactor-python: new cdylib crate re-exporting the PyO3 bindings (Runtime/RuntimeConfig/RuntimeHandle/Inbox/Ctx/ActorAddress/RuntimeStats), depending on `swactor` + pyo3; pyproject.toml and uv.lock relocated here from the root
- crates/swactor-wasm: new cdylib crate moved from top-level `wasm/`, depending on `swactor` with `no_random` features
- src/actor.rs: widen `Actor::new`, `AnyActor`, `ContextInner`, and `Ctx::raw_inner` to `pub` so the separate binding crates can drive the runtime
- src/lib.rs: delete the in-tree `python` module and `#[pymodule]`, and gate the `no_random` RNG behind `all(feature = "no_random", not(feature = "getrandom"))`
- tools/: relocate package.json/package-lock.json; drop the now-duplicate `wasm/Cargo.lock`
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-02-07 17:39:02 +00:00
|
|
|
#[cfg(all(feature = "no_random", not(feature = "getrandom")))]
|
feat: Stress tests, benchmarking, and non-failing queues and inboxes #3
Adds some basic benchmarking, stress tests. They still need to be properly examined to ensure they are testing the correct properties, but fit for "good enough". Implements the HybridChannel type, which features a channel buffer that can withstand overflows. It does so by providing a dequeue behind a mutex. Without overflow, will push messages into the lock free ArrayQueue implemented by crossbeam_queue; when that buffer fills, will use the locking portion provided by the Mutex<VecDequeue>.
In the future we can even further optimize this, perhaps with some linked list implementations of lock-free channels, but, like the benchmarks, this fits the "good enough" bar for now.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-01-26 07:14:00 +00:00
|
|
|
pub(crate) fn get_random(buf: &mut [u8]) {
|
|
|
|
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
|
|
|
|
|
|
|
|
|
static COUNTER: AtomicUsize = AtomicUsize::new(0);
|
|
|
|
|
|
|
|
|
|
let value = COUNTER.fetch_add(1, Ordering::Relaxed);
|
|
|
|
|
let bytes = value.to_ne_bytes();
|
|
|
|
|
|
|
|
|
|
for (i, byte) in buf.iter_mut().enumerate() {
|
|
|
|
|
*byte = bytes[i % core::mem::size_of::<usize>()];
|
|
|
|
|
}
|
|
|
|
|
}
|