Typed-actor runtime operations: spawn, stop, send, introspect.

Runtime-facing surface for actor modules compiled from actor containers. Every function here delegates to Cure.Actor.Builtins, which calls Cure.Actor.Runtime. Spawning captures the caller as the actor's :caller.

Examples

use Std.Actor

let pid = spawn(:"Cure.Actor.Echo")
send(pid, %[:ping, :hello])
is_alive(pid)                           # => true
stop(pid)
use Std.Actor

# Name an actor so other processes can find it without passing a pid.
let pid = spawn_named(:"Cure.Actor.Cache", "main-cache")
lookup("main-cache") == pid             # => true

Functions

  • # fn __group__() -> Atom

    Group tag consumed by Cure.Stdlib.Preload.

  • # fn get_state(pid: Pid) -> Any extern

    Fetch the actor's current user-visible payload.

  • # fn is_alive(pid: Pid) -> Bool extern

    true when the actor pid is still alive.

  • # fn lookup(name: String) -> Pid extern

    Look up an actor by its registered name; returns its pid.

  • # fn send(pid: Pid, message: Any) -> Any extern

    Send a message to an actor (cast semantics: fire-and-forget). This is the runtime counterpart of the Melquiades operator <-|; both lower to Erlang's ! and return the sent message.

  • # fn spawn(actor_module: Atom) -> Pid extern

    Spawn a new actor instance from a compiled actor module atom. The spawning process is recorded as the actor's caller automatically; lifecycle hooks can reach it via Std.Actor.notify/1 (see the runtime docs).

  • # fn spawn_named(actor_module: Atom, name: String) -> Pid extern

    Spawn a named actor. The name string is registered with the runtime so it can be found later via lookup/1.

  • # fn spawn_with_payload(actor_module: Atom, payload: Any) -> Pid extern

    Spawn an actor with an explicit initial payload.

  • # fn stop(pid: Pid) -> Atom extern

    Stop a running actor instance.