Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFullExecutor = errors.New("pool has no idle goroutine")
ErrFullExecutor is returned by the executor created by NewAbortOnFullExecutor if there are no goroutines available to run a task.
Functions ¶
This section is empty.
Types ¶
type ExecuteCloser ¶
type ExecuteCloser interface { Executor // Close signals the goroutines in this executor to stop. Close() error }
ExecuteCloser adds io.Closer to Executor.
func NewAbortOnFullExecutor ¶
func NewAbortOnFullExecutor(n int) ExecuteCloser
NewAbortOnFullExecutor returns a new Executor that will return NewAbortOnFullExecutor if a new pool of n goroutines has no idle worker to pick up a task.
Passing n == 0 effectively an executor that always returns NewAbortOnFullExecutor. Panics if n < 0.
func NewCallerRunsOnFullExecutor ¶
func NewCallerRunsOnFullExecutor(n int) ExecuteCloser
NewCallerRunsOnFullExecutor returns a new Executor that will execute the command on same goroutine as caller if a new pool of n goroutines is full.
Passing n == 0 effectively returns an always-caller-run executor. Panics if n < 0.
type Executor ¶
type Executor interface { // Execute executes the given command. // // The return error comes from the executor's attempt to run the function, not from the function itself. Execute(func()) error }
Executor is inspired by Java Executor that abstracts submitting a task and executing it.