Trait heph::spawn::Spawn[][src]

pub trait Spawn<S, NA, RT>: PrivateSpawn<S, NA, RT> {
    fn try_spawn(
        &mut self,
        supervisor: S,
        new_actor: NA,
        arg: NA::Argument,
        options: ActorOptions
    ) -> Result<ActorRef<NA::Message>, NA::Error>
    where
        S: Supervisor<NA>,
        NA: NewActor<RuntimeAccess = RT>
, { ... }
fn spawn(
        &mut self,
        supervisor: S,
        new_actor: NA,
        arg: NA::Argument,
        options: ActorOptions
    ) -> ActorRef<NA::Message>
    where
        S: Supervisor<NA>,
        NA: NewActor<Error = !, RuntimeAccess = RT>
, { ... } }
Expand description

The Spawn trait defines how new actors are added to the runtime.

Provided methods

Attempts to spawn an actor.

Arguments:

  • supervisor: all actors need supervision, the supervisor is the supervisor for this actor, see the Supervisor trait for more information.
  • new_actor: the NewActor implementation that defines how to start the actor.
  • arg: the argument(s) passed when starting the actor, and
  • options: the actor options used to spawn the new actors.

When using a NewActor implementation that never returns an error, such as the implementation provided by async functions, it’s easier to use the spawn method.

Spawn an actor.

This is a convenience method for NewActor implementations that never return an error, such as asynchronous functions.

See Spawn::try_spawn for more information.

Implementors