111 lines
4.0 KiB
Rust
111 lines
4.0 KiB
Rust
//! # smarm — Silly Marks Abstract Rust Machine
|
|
//!
|
|
//! Erlang-style green-thread actor concurrency for Rust.
|
|
//!
|
|
//! Multi-threaded: N scheduler OS threads (default: one per CPU) share a
|
|
//! single global run queue behind a `Mutex`. Actors communicate by sending
|
|
//! `Send` messages over channels; every actor has a supervisor. Synchronisation
|
|
//! primitives — `Mutex<T>` with mandatory lock timeouts, channel `recv`,
|
|
//! `sleep`, and epoll-backed `wait_readable`/`wait_writable` — all park the
|
|
//! green thread, never the OS thread.
|
|
//!
|
|
//! See `LOOM.md` for the design intent and the deferred-for-later list.
|
|
|
|
pub mod actor;
|
|
pub mod causal;
|
|
pub mod channel;
|
|
pub mod context;
|
|
pub mod gen_server;
|
|
pub mod gen_statem;
|
|
pub mod introspect;
|
|
pub mod io;
|
|
pub mod link;
|
|
pub mod monitor;
|
|
pub mod mutex;
|
|
#[cfg(feature = "observer")]
|
|
pub mod observer;
|
|
pub(crate) mod park;
|
|
pub mod pg;
|
|
pub mod pid;
|
|
pub mod preempt;
|
|
pub(crate) mod raw_mutex;
|
|
pub mod registry;
|
|
#[doc(hidden)] // pub only so benches/rq_micro.rs can drive the raw structures
|
|
pub mod run_queue;
|
|
pub mod runtime;
|
|
pub mod scheduler;
|
|
pub(crate) mod signal;
|
|
pub(crate) mod slot_state;
|
|
pub mod stack;
|
|
pub mod supervisor;
|
|
pub(crate) mod sync_shim;
|
|
pub mod timer;
|
|
pub mod trace;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Global allocator
|
|
// ---------------------------------------------------------------------------
|
|
|
|
#[global_allocator]
|
|
static ALLOCATOR: preempt::PreemptingAllocator = preempt::PreemptingAllocator;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Public API re-exports
|
|
// ---------------------------------------------------------------------------
|
|
|
|
pub use channel::{
|
|
channel, select, select_timeout, try_select, try_select_timeout, Receiver, RecvError,
|
|
RecvTimeoutError, Selectable, Sender,
|
|
};
|
|
pub use gen_server::{
|
|
call, cast, shutdown, whereis_server, CallError, CallTimeoutError, CastError, GenServer,
|
|
GenServerBuilder, GenServerCtx, GenServerName, GenServerRef, NamedGenServerBuilder,
|
|
ShutdownAction, StopHandle, TimerHandle, Watcher,
|
|
};
|
|
pub use gen_statem::{
|
|
CallError as GenStatemCallError, Cx, GenStatemName, GenStatemRef, Machine, Reply, Resolution,
|
|
SendError as GenStatemSendError,
|
|
};
|
|
pub use introspect::{
|
|
actor_info, snapshot, tree, tree_from, ActorInfo, ActorState, RuntimeSnapshot, RuntimeTree,
|
|
StackInfo, TreeNode, SNAPSHOT_FORMAT_VERSION,
|
|
};
|
|
pub use link::{link, trap_exit, unlink, ExitSignal};
|
|
pub use monitor::{
|
|
demonitor, mark_watchable, monitor, terminal_reason, Down, DownReason, Monitor, MonitorId,
|
|
};
|
|
pub use mutex::{LockTimeout, Mutex, MutexGuard};
|
|
#[cfg(feature = "observer")]
|
|
pub use observer::{ObserverReply, ObserverRequest};
|
|
pub use pg::{
|
|
dispatch, join, leave, members, members_as, pick, pick_as, Incarnation, Member, NodeId,
|
|
};
|
|
pub use pid::{Addressable, Erased, Name, Pid, RawPid};
|
|
pub use registry::{
|
|
install, lookup_as, register, resolve_name, send, send_dyn, send_to, unregister, whereis,
|
|
NameResolution, RegisterError, SendError,
|
|
};
|
|
pub use runtime::{init, Config, Runtime, RuntimeHandle};
|
|
pub use scheduler::{
|
|
block_on_io, cancel_timer, request_shutdown, request_stop, run, self_pid, send_after,
|
|
send_after_named, send_after_named_wall, send_after_wall, sleep, sleep_wall, spawn, spawn_addr,
|
|
spawn_addr_with, spawn_monitor, spawn_monitor_with, spawn_under, spawn_under_with, spawn_with,
|
|
try_spawn, try_spawn_under_with, wait_readable, wait_readable_timeout, wait_writable,
|
|
wait_writable_timeout, yield_now, FdArm, JoinError, JoinHandle, SpawnError, SpawnOpts,
|
|
};
|
|
pub use supervisor::{ChildSpec, OneForOne, Restart, Shutdown, Signal, Strategy};
|
|
pub use timer::TimerId;
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// check!()
|
|
// ---------------------------------------------------------------------------
|
|
|
|
/// Voluntarily check whether this actor's timeslice has expired, yielding
|
|
/// if so.
|
|
#[macro_export]
|
|
macro_rules! check {
|
|
() => {
|
|
$crate::preempt::maybe_preempt()
|
|
};
|
|
}
|