Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct { Tasks []*Task // contains filtered or unexported fields }
Pool is a worker group that runs a number of tasks at a configured concurrency.
func NewPool ¶
NewPool initializes a new pool with the given tasks and at the given concurrency.
type PoolWithContext ¶
type PoolWithContext struct { Tasks []*TaskWithContext CancelHandler *cancelHandler IsPoolCanceled bool // contains filtered or unexported fields }
PoolWithContext is a worker group that runs a number of tasks at a configured concurrency.
func NewPoolWithContext ¶
func NewPoolWithContext(tasks []*TaskWithContext, concurrency int) *PoolWithContext
NewPoolWithContext initializes a new pool with the given tasks and at the given concurrency.
type Task ¶
type Task struct { // Err holds an error that occurred during a task. Its // result is only meaningful after Run has been called // for the pool that holds it. Err error Data interface{} // contains filtered or unexported fields }
Task encapsulates a work item that should go in a work pool.
func NewTask ¶
NewTask initializes a new task based on a given work function.
type TaskWithContext ¶
type TaskWithContext struct { // Err holds an error that occurred during a task. Its // result is only meaningful after Run has been called // for the pool that holds it. Err error Data interface{} // contains filtered or unexported fields }
TaskWithContext encapsulates a work item that should go in a work pool.
func NewTaskWithContext ¶
func NewTaskWithContext(d interface{}, f func(data interface{}) error) *TaskWithContext
NewTaskWithContext initializes a new task based on a given work function.
func (*TaskWithContext) Run ¶
func (t *TaskWithContext) Run(p *PoolWithContext)
Run runs a Task and does appropriate accounting via a