Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RoutineGroup ¶
type RoutineGroup struct {
// contains filtered or unexported fields
}
A RoutineGroup is used to group goroutines together and all wait all goroutines to be done.
func (*RoutineGroup) Run ¶
func (g *RoutineGroup) Run(fn func())
Run runs the given fn in RoutineGroup. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup) RunSafe ¶
func (g *RoutineGroup) RunSafe(fn func())
RunSafe runs the given fn in RoutineGroup, and avoid panics. Don't reference the variables from outside, because outside variables can be changed by other goroutines
func (*RoutineGroup) Wait ¶
func (g *RoutineGroup) Wait()
Wait waits all running functions to be done.
type TaskRunner ¶
type TaskRunner struct {
// contains filtered or unexported fields
}
A TaskRunner is used to control the concurrency of goroutines.
func NewTaskRunner ¶
func NewTaskRunner(concurrency int) *TaskRunner
NewTaskRunner returns a TaskRunner.
func (*TaskRunner) Schedule ¶
func (rp *TaskRunner) Schedule(task func())
Schedule schedules a task to run under concurrency control.
type WorkerGroup ¶
type WorkerGroup struct {
// contains filtered or unexported fields
}
A WorkerGroup is used to run given number of workers to process jobs.
func NewWorkerGroup ¶
func NewWorkerGroup(job func(), workers int) WorkerGroup
NewWorkerGroup returns a WorkerGroup with given job and workers.