Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run starts all actors and waits for the first one to finish. Once one actor has returned the others are interrupted. Run then waits for all actors to finish.
Run returns the error of the first actor to finish. If that actor returns nil, then Run will also return nil, even if other actors return a non-nil error.
If Run is called without any actors it will return nil immediately.
Types ¶
type Actor ¶
type Actor interface { // Execute runs some computation. Execute() error // Interrupt stops the actor. Interrupt should not wait for Execute to // return and it must be safe to be called multiple times. Interrupt() }
Actor represents a long running task that can be interrupted.
func Done ¶
Done returns an actor that immediately returs the given result when executed. This can be used when there is a problem setting up an actor to get the error to the function calling Run.
func WithChannel ¶
WithChannel creates an actor from a function that takes a channel. When the actor is interrupted the channel given to the function is closed.