pub struct ActorSystem { /* private fields */ }Expand description
Unified system for all concurrent work.
Provides:
- Actor spawning on a shared work-stealing pool
- CPU-bound compute with admission control
- Graceful shutdown via cancellation token
Implementations§
Source§impl ActorSystem
impl ActorSystem
Sourcepub fn new(config: ActorSystemConfig) -> Self
pub fn new(config: ActorSystemConfig) -> Self
Create a new actor system with the given configuration.
pub fn scope(&self) -> Self
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Get the cancellation token for this system.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the system has been cancelled.
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Signal shutdown to all actors and the timer scheduler.
Cancels all actors, wakes any that are parked, then drops the waker and keepalive references so actor cells can be freed.
Sourcepub fn join(&self) -> Result<(), JoinError>
pub fn join(&self) -> Result<(), JoinError>
Wait for all actors to finish after shutdown, with a default 5-second timeout.
Sourcepub fn join_timeout(&self, timeout: Duration) -> Result<(), JoinError>
pub fn join_timeout(&self, timeout: Duration) -> Result<(), JoinError>
Wait for all actors to finish after shutdown, with a custom timeout.
Sourcepub fn scheduler(&self) -> &SchedulerHandle
pub fn scheduler(&self) -> &SchedulerHandle
Get the timer scheduler for scheduling delayed/periodic callbacks.
Sourcepub fn spawn<A: Actor>(&self, name: &str, actor: A) -> ActorHandle<A::Message>
pub fn spawn<A: Actor>(&self, name: &str, actor: A) -> ActorHandle<A::Message>
Spawn an actor on the shared work-stealing pool.
Returns a handle to the spawned actor.
Sourcepub fn install<R, F>(&self, f: F) -> R
pub fn install<R, F>(&self, f: F) -> R
Executes a closure on the rayon thread pool directly.
Synchronous and bypasses admission control. Use this when you’re already in a synchronous context and need parallel execution.
Trait Implementations§
Source§impl Clone for ActorSystem
impl Clone for ActorSystem
Source§fn clone(&self) -> ActorSystem
fn clone(&self) -> ActorSystem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ActorSystem
impl !RefUnwindSafe for ActorSystem
impl Send for ActorSystem
impl Sync for ActorSystem
impl Unpin for ActorSystem
impl UnsafeUnpin for ActorSystem
impl !UnwindSafe for ActorSystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more