Context
A method receives its Context a: the actor’s view of itself and the system. With ctxOf ctx it gives the engine’s
Ctx msg, which the functions of Actor.System and Actor.Timer take.
From a method
| Function |
Type |
Meaning |
self |
Context a -> Address a |
This actor’s address |
childActorOf |
Context a -> Parameters -> Address b |
A child, supervised by this actor |
ctxOf |
Context a -> Ctx (Message a) |
The engine’s context |
The system (Actor.System)
| Function |
Type |
Meaning |
actorSystem |
() -> ActorSystem |
A new system: root, /user, /system, /temp, registry, dead letters |
spawnActor |
ActorSystem -> Behavior msg state -> ActorRef msg |
An actor under /user |
spawnSystemActor |
ActorSystem -> Behavior msg state -> ActorRef msg |
Under /system |
spawnTemp |
ActorSystem -> Behavior msg state -> ActorRef msg |
Under /temp |
spawnChild |
Ctx msg -> Behavior child cstate -> ActorRef child |
A child of this actor |
selfRef |
Ctx msg -> ActorRef msg |
This actor’s reference |
processes |
ActorSystem -> String -> [Pid] |
Running actors on a route ("*" for all), oldest first |
processCount |
ActorSystem -> Int |
How many run |
deadLetters |
ActorSystem -> [DeadLetter] |
Messages that reached stopped actors |
kill |
ActorSystem -> Int -> () |
Stop the actor with this id |
shutdown, shutdownAndWait |
ActorSystem -> () |
Stop everything (and wait) |
Death watch
| Function |
Type |
Meaning |
watch |
Ctx msg -> ActorRef other -> msg -> () |
Be told msg when the other stops (at once if it has) |
unwatch |
Ctx msg -> ActorRef other -> () |
Take the watch back |
watching |
ActorRef other -> ActorRef msg -> msg -> () |
A watch from outside an actor |
unwatching |
ActorRef other -> ActorRef msg -> () |
Take it back |
Stopping
| Function |
Type |
Meaning |
stopActor |
ActorRef msg -> () |
Stop after its current message |
stopAndWait |
ActorRef msg -> () |
The same, and wait until it has stopped |
Timers (Actor.Timer)
| Function |
Type |
Meaning |
scheduleOnce |
Int -> ActorRef msg -> msg -> Timer |
Tell once, after ms |
scheduleRepeat |
Int -> ActorRef msg -> msg -> Timer |
Tell every ms, until cancelled or the actor stops |
cancel |
Timer -> () |
Nothing more is told |
isScheduled |
Timer -> Bool |
Whether it still runs |
Lifecycle hooks
Set on a behaviour: see Actor and Lifecycle.