Struct tonari_actor::System
source · [−]pub struct System { /* private fields */ }Expand description
Systems are responsible for keeping track of their spawned actors, and managing their lifecycles appropriately.
You may run multiple systems in the same application, each system being responsible for its own pool of actors.
Implementations
sourceimpl System
impl System
pub fn with_callbacks(name: &str, callbacks: SystemCallbacks) -> Self
sourcepub fn prepare<A>(&mut self, actor: A) -> SpawnBuilder<'_, A, impl FnOnce() -> A>where
A: Actor + 'static,
pub fn prepare<A>(&mut self, actor: A) -> SpawnBuilder<'_, A, impl FnOnce() -> A>where
A: Actor + 'static,
Prepare an actor to be spawned. Returns a SpawnBuilder
which can be used to customize the spawning of the actor.
sourcepub fn prepare_fn<A, F>(&mut self, factory: F) -> SpawnBuilder<'_, A, F>where
A: Actor + 'static,
F: FnOnce() -> A + Send + 'static,
pub fn prepare_fn<A, F>(&mut self, factory: F) -> SpawnBuilder<'_, A, F>where
A: Actor + 'static,
F: FnOnce() -> A + Send + 'static,
Similar to prepare, but an actor factory is passed instead
of an Actor itself. This is used when an actor needs to be
created on its own thread instead of the calling thread.
Returns a SpawnBuilder which can be used to customize the
spawning of the actor.
sourcepub fn spawn<A>(&mut self, actor: A) -> Result<Addr<A>, ActorError>where
A: Actor<Context = Context<<A as Actor>::Message>> + Send + 'static,
pub fn spawn<A>(&mut self, actor: A) -> Result<Addr<A>, ActorError>where
A: Actor<Context = Context<<A as Actor>::Message>> + Send + 'static,
Spawn a normal Actor in the system, returning its address when successful.
sourcepub fn run(&mut self) -> Result<(), ActorError>
pub fn run(&mut self) -> Result<(), ActorError>
Block the current thread until the system is shutdown.
Methods from Deref<Target = SystemHandle>
sourcepub fn shutdown(&self) -> Result<(), ActorError>
pub fn shutdown(&self) -> Result<(), ActorError>
Stops all actors spawned by this system.
sourcepub fn subscribe_recipient<M: 'static, E: Event + Into<M>>(
&self,
recipient: Recipient<M>
)
pub fn subscribe_recipient<M: 'static, E: Event + Into<M>>(
&self,
recipient: Recipient<M>
)
Subscribe given recipient to events of type E. See Context::subscribe().
pub fn is_running(&self) -> bool
Trait Implementations
sourceimpl Deref for System
impl Deref for System
type Target = SystemHandle
type Target = SystemHandle
The resulting type after dereferencing.
Auto Trait Implementations
impl !RefUnwindSafe for System
impl Send for System
impl Sync for System
impl Unpin for System
impl !UnwindSafe for System
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more