Documentation ¶
Overview ¶
Package otp implements Erlang-inspired concurrency patterns.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Recv ¶
Recv checks mb to see if any messages that have been sent to it are matched by the given function. A message is considered to be a match if it both can be type asserted to T and the match function returns true. If there is such a message, it is removes from the Mailbox and returned. If there is no such message, Recv blocks until such a message arrives.
If match is nil, all messages will be considered to be matching.
For a non-blocking variant that returns immediately whether or not a matching message is present, see TryRecv.
Types ¶
type Mailbox ¶
type Mailbox struct {
// contains filtered or unexported fields
}
Mailbox is an OTP process mailbox. It works similarly to a channel but is not tied to a specific type and features a dynamic buffer. Sends to a mailbox are always asynchronous. A zero-value Mailbox is ready to use.
type MonitoredProcessExited ¶
type MonitoredProcessExited struct {
Proc *Proc
}
MonitoredProcessExited is a message sent to processes that are monitoring another process when the monitored process exits. See [Process.Monitor].
type Proc ¶
type Proc struct {
// contains filtered or unexported fields
}
Proc is an OTP process.
func Go ¶
Go runs f as an OTP process. The passed context will be canceled when the process is requested to exit, as well as if the process exits on its own. If f panics with an error, it will be recovered from and treated as though that error had been returned. Non-error panic values will be repanicked.
The current process can be retrieved from the provided context using the Self function.
func (*Proc) Done ¶
func (p *Proc) Done() <-chan struct{}
Done returns a channel that will be closed once the process has fully exited.
func (*Proc) Monitor ¶
Monitor registers s as monitoring p. When p exits, all monitoring processes will be sent a MonitoredProcessExited message.
If p has already exited when Monitor is called, the message will be sent to s immediately.
func (*Proc) Stop ¶
func (p *Proc) Stop()
Stop signals to the process that it should exit by canceling its root context.