Process
Processes
Names and subjects for addressing a running process.
Local names use namedSubject. For a registered name on another connected node, use remoteSubject (needs --sname / --name distribution).
This module is selm stdlib for target = "erlang". Browser apps use the client platform Process (Id / spawn / kill / Task sleep), not Subject / call / listen. See fixtures/process_dual and examples/02_counter.
Types
Name
type Name a = NameA registry name for a process that handles messages of type a.
Examples
Process.newName "counter"Subject
type Subject a = SubjectAn address for sending messages of type a.
Examples
Process.namedSubject namePid
type Pid = PidThe operating-system identity of a running process.
Examples
Process.selfValues
newName
newName : String -> Name aCreate a registry name for a process.
Examples
Process.newName "counter"namedSubject
namedSubject : Name a -> Subject aAddress a process by its registered name on this node.
Examples
Process.namedSubject nameremoteSubject
remoteSubject : Name a -> Node -> Subject aAddress a registered name on another node.
Both nodes must be distributed and share a cookie. The remote process still uses listen on that name locally.
Examples
Process.remoteSubject name otherNodenewSubject
newSubject : Subject aAllocate a fresh subject (reply address).
Examples
Process.newSubjectsend
send : Subject a -> a -> ()Send a message to a subject.
Examples
Process.send subject Incrcall
call : Subject a -> Int -> (Subject b -> a) -> bSend a message and wait for the reply.
Examples
Process.call subject 5000 (\reply -> Get reply)reply
reply : Subject a -> a -> Cmd msgAnswer a Process.call from update. The command sends the value to the reply subject.
Examples
Process.reply replyTo 42listen
listen : Name a -> (a -> msg) -> Sub msgDeliver messages sent to a name into the running program.
Examples
Process.listen name GotMsgself
self : PidThe pid of the calling process.
Examples
Process.selfsleep
sleep : Int -> ()Block the current process for the given milliseconds.
Examples
Process.sleep 100