Documentation ¶
Index ¶
Constants ¶
const ( POOL_RUN = iota POOL_FINISH POOL_ABORT )
Variables ¶
var PoolAbortedErr = errors.New("pool has been aborted")
Functions ¶
This section is empty.
Types ¶
type Bucket ¶ added in v0.2.0
type Bucket interface { Push(interface{}) PushAll([]interface{}) Pop() interface{} IsEmpty() bool Empty() }
type Pool ¶ added in v0.2.0
type Pool struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.2.0
Constructs a new Cuba thread pool.
The worker callback will be called by multiple goroutines in parallel, so is expected to be thread safe.
Bucket affects the order that items will be processed in. cuba.NewQueue() provides FIFO ordering, while cuba.NewStack() provides LIFO ordered work.
func (*Pool) Finish ¶ added in v0.2.0
func (pool *Pool) Finish()
Calling Finish() waits for all work to complete, and allows goroutines to shut down.
func (*Pool) Push ¶ added in v0.2.0
Push an item into the worker pool. This will be scheduled to run on a worker immediately.
func (*Pool) PushAll ¶ added in v0.2.0
Push multiple items into the worker pool.
Compared to Push() this only aquires the lock once, so may reduce lock contention.
func (*Pool) SetMaxWorkers ¶ added in v0.2.0
Sets the maximum number of worker goroutines.
Default: runtime.NumCPU() (i.e. the number of CPU cores available)