Documentation

Lapis.Concurrent.Actor

Actor Types #

A handle to send messages to an actor. Can be freely cloned and shared across threads.

Instances For
    def Lapis.Concurrent.Actor.ActorRef.send {Msg : Type} (ref : ActorRef Msg) (msg : Msg) :

    Send a message to the actor

    Equations
    Instances For
      def Lapis.Concurrent.Actor.ActorRef.call {Resp Msg : Type} [Nonempty Resp] (ref : ActorRef Msg) (mkMsg : Channel.Oneshot RespMsg) :
      IO Resp

      Send a message and get a response via oneshot channel

      Equations
      Instances For
        def Lapis.Concurrent.Actor.ActorRef.trySend {Msg : Type} (ref : ActorRef Msg) (msg : Msg) :

        Try to send without blocking (always succeeds for unbounded)

        Equations
        Instances For

          Actor lifecycle state

          Instances For
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              Configuration for actor behavior

              • name : String

                Name for debugging/logging

              • restartOnPanic : Bool

                Whether to restart on handler panic

              Instances For
                structure Lapis.Concurrent.Actor.Actor (Msg State : Type) :

                A running actor instance

                Instances For
                  def Lapis.Concurrent.Actor.Actor.isRunning {Msg State : Type} (actor : Actor Msg State) :

                  Check if the actor is still running

                  Equations
                  Instances For
                    def Lapis.Concurrent.Actor.Actor.stop {Msg State : Type} (actor : Actor Msg State) :

                    Request the actor to stop (gracefully)

                    Equations
                    Instances For
                      def Lapis.Concurrent.Actor.Actor.join {Msg State : Type} (actor : Actor Msg State) :

                      Wait for the actor to finish

                      Equations
                      Instances For
                        def Lapis.Concurrent.Actor.Actor.shutdown {Msg State : Type} (actor : Actor Msg State) :

                        Stop and wait for the actor to finish

                        Equations
                        Instances For
                          def Lapis.Concurrent.Actor.Actor.getRef {Msg State : Type} (actor : Actor Msg State) :

                          Get the actor's reference for sending messages

                          Equations
                          Instances For

                            Actor Spawning #

                            Message handler result

                            Instances For
                              def Lapis.Concurrent.Actor.spawn {State Msg : Type} (initialState : State) (handler : StateMsgIO (HandleResult State)) (config : ActorConfig := { }) :
                              IO (Actor Msg State)

                              Spawn a new actor with the given initial state and message handler. The handler is called sequentially for each message.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                def Lapis.Concurrent.Actor.spawnWithErrorHandler {State Msg : Type} (initialState : State) (handler : StateMsgIO (HandleResult State)) (onError : StringIO Unit) (config : ActorConfig := { }) :
                                IO (Actor Msg State)

                                Spawn an actor that can handle IO errors gracefully

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For

                                  Typed Request-Response Pattern #

                                  structure Lapis.Concurrent.Actor.Request (Req Resp : Type) :

                                  A request message that expects a response

                                  Instances For
                                    def Lapis.Concurrent.Actor.Request.new {Resp Req : Type} [Nonempty Resp] (payload : Req) :
                                    IO (Request Req Resp × Channel.Oneshot Resp)

                                    Create a request and get the response channel

                                    Equations
                                    Instances For
                                      def Lapis.Concurrent.Actor.Request.reply {Req Resp : Type} (req : Request Req Resp) (response : Resp) :

                                      Reply to a request

                                      Equations
                                      Instances For
                                        def Lapis.Concurrent.Actor.ask {Resp Msg Req : Type} [Nonempty Resp] (ref : ActorRef Msg) (mkRequest : Request Req RespMsg) (payload : Req) :
                                        IO Resp

                                        Send a request to an actor and wait for response

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For

                                          Actor Supervision #

                                          A supervisor that manages multiple actors

                                          Instances For

                                            Create a new supervisor

                                            Equations
                                            Instances For
                                              def Lapis.Concurrent.Actor.Supervisor.supervise {Msg State : Type} (sup : Supervisor) (actor : Actor Msg State) :

                                              Add an actor to supervision

                                              Equations
                                              Instances For

                                                Shutdown all supervised actors

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For

                                                  Utility Functions #

                                                  Create an actor ref from an existing mailbox

                                                  Equations
                                                  Instances For
                                                    def Lapis.Concurrent.Actor.broadcast {Msg : Type} (refs : Array (ActorRef Msg)) (msg : Msg) :

                                                    Broadcast a message to multiple actors

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For