Skip to main content

RemoteSpawn

Trait RemoteSpawn 

Source
pub trait RemoteSpawn:
    Actor
    + Referable
    + Binds<Self> {
    type Params: RemoteMessage;

    // Required method
    fn new<'async_trait>(
        params: Self::Params,
        environment: Flattrs,
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
       where Self: 'async_trait;

    // Provided methods
    fn gspawn_root_bind(
        proc: &Proc,
        uid: Uid,
        serialized_params: Data,
        environment: Flattrs,
    ) -> Pin<Box<dyn Future<Output = Result<ActorAddr, Error>> + Send>> { ... }
    fn gspawn_child(
        proc: &Proc,
        parent: InstanceCell,
        uid: Uid,
        serialized_params: Data,
        environment: Flattrs,
    ) -> Pin<Box<dyn Future<Output = Result<AnyActorHandle, Error>> + Send>> { ... }
    fn get_type_id() -> TypeId { ... }
}
Expand description

An Actor that can be spawned remotely.

Bounds explained:

  • Actor: only actors may be remotely spawned.
  • Referable: marks the type as eligible for typed remote references (ActorRef<A>); required because remote spawn ultimately hands back an ActorAddr that higher-level APIs may re-type as ActorRef<A>.
  • Binds<Self>: lets the runtime wire this actor’s handler ports when it is spawned (the blanket impl calls handle.bind::<Self>()).

gspawn_root_bind is a type-erased entry point used by the remote spawn/registry machinery. It takes serialized params and returns the new actor’s ActorAddr; application code shouldn’t call it directly.

Required Associated Types§

Source

type Params: RemoteMessage

The type of parameters used to instantiate the actor remotely.

Required Methods§

Source

fn new<'async_trait>( params: Self::Params, environment: Flattrs, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait,

Creates a new actor instance given its instantiation parameters. The environment allows whoever is responsible for spawning this actor to pass in additional context that may be useful.

Provided Methods§

Source

fn gspawn_root_bind( proc: &Proc, uid: Uid, serialized_params: Data, environment: Flattrs, ) -> Pin<Box<dyn Future<Output = Result<ActorAddr, Error>> + Send>>

A type-erased entry point to spawn this actor as a root. This is primarily used by hyperactor’s remote actor registration mechanism.

Source

fn gspawn_child( proc: &Proc, parent: InstanceCell, uid: Uid, serialized_params: Data, environment: Flattrs, ) -> Pin<Box<dyn Future<Output = Result<AnyActorHandle, Error>> + Send>>

A type-erased entry point to spawn this actor as a child.

The returned handle is lifecycle-only; callers that know the concrete actor type can recover a typed handle with AnyActorHandle::downcast.

Source

fn get_type_id() -> TypeId

The type ID of this actor.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl RemoteSpawn for PingPongActor

Source§

impl<A: Actor + Referable + Binds<Self> + Default> RemoteSpawn for A

If an actor implements Default, we use this as the RemoteSpawn implementation, too.