Documentation ¶
Overview ¶
Package pool provides access to a mixer-global pool of buffers, a pool of goroutines, and a string interning table.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GoroutinePool ¶
type GoroutinePool struct {
// contains filtered or unexported fields
}
GoroutinePool represents a set of reusable goroutines onto which work can be scheduled.
func NewGoroutinePool ¶
func NewGoroutinePool(queueDepth int, singleThreaded bool) *GoroutinePool
NewGoroutinePool creates a new pool of goroutines to schedule async work.
func (*GoroutinePool) AddWorkers ¶
func (gp *GoroutinePool) AddWorkers(numWorkers int)
AddWorkers introduces more goroutines in the worker pool, increasing potential parallelism.
func (*GoroutinePool) Close ¶
func (gp *GoroutinePool) Close() error
Close waits for all goroutines to terminate (and implements io.Closer).
func (*GoroutinePool) ScheduleWork ¶
func (gp *GoroutinePool) ScheduleWork(fn WorkFunc, param interface{})
ScheduleWork registers the given function to be executed at some point. The given param will be supplied to the function during execution.
By making use of the supplied parameter, it is possible to avoid allocation costs when scheduling the work function. The caller needs to make sure that function fn only depends on external data through the passed in param interface{} and nothing else.
A way to ensure this condition is met, is by passing ScheduleWork a normal named function rather than an inline anonymous function. It's easy for code in an anonymous function to have (or gain) an accidental reference that causes a closure to silently be created.