Documentation
¶
Overview ¶
Example ¶
tasks, err := taskqueue.FromList([]taskqueue.Task{{
Name: "init",
}, {
Name: "partA",
Deps: []string{"init"},
}, {
Name: "partB",
Deps: []string{"partB"},
}, {
Name: "finalize",
Deps: []string{"partA", "partB"},
}})
if err != nil {
fmt.Println(err.Error())
return
}
work, done := taskqueue.Start(tasks)
taskqueue.RunOnPool(work, done, pool.New(), func(name string) {
fmt.Printf("Running %s\n", name)
})
Index ¶
- Variables
- func RunOnContextPool(work <-chan string, completed chan<- string, pool interface{ ... }, ...) error
- func RunOnErrorPool(work <-chan string, completed chan<- string, pool interface{ ... }, ...) error
- func RunOnPool(work <-chan string, completed chan<- string, pool interface{ ... }, ...)
- func RunOnResultContextPool[T any](work <-chan string, completed chan<- string, pool interface{ ... }, ...) ([]T, error)
- func RunOnResultErrorPool[T any](work <-chan string, completed chan<- string, pool interface{ ... }, ...) ([]T, error)
- func RunOnResultPool[T any](work <-chan string, completed chan<- string, pool interface{ ... }, ...) []T
- func Start(tasks TaskSet) (start <-chan string, done chan<- string)
- type Task
- type TaskSet
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateName = errors.New("duplicate task name")
var ErrEmptyName = errors.New("task name is empty")
var ErrNameMismatch = errors.New("task name mismatch")
var ErrUnknownDep = errors.New("unknown dependency name")
Functions ¶
func RunOnContextPool ¶
func RunOnContextPool(work <-chan string, completed chan<- string, pool interface { Go(func(context.Context) error) Wait() error }, handler func(context.Context, string) error) error
For use with conc.ContextPool
func RunOnErrorPool ¶
func RunOnErrorPool(work <-chan string, completed chan<- string, pool interface { Go(func() error) Wait() error }, handler func(string) error) error
For use with conc.ErrorPool
func RunOnPool ¶
func RunOnPool(work <-chan string, completed chan<- string, pool interface { Go(func()) Wait() }, handler func(string))
For use with conc.Pool
func RunOnResultContextPool ¶
func RunOnResultContextPool[T any](work <-chan string, completed chan<- string, pool interface { Go(func(context.Context) (T, error)) Wait() ([]T, error) }, handler func(context.Context, string) (T, error)) ([]T, error)
For use with conc.ResultContextPool
func RunOnResultErrorPool ¶
func RunOnResultErrorPool[T any](work <-chan string, completed chan<- string, pool interface { Go(func() (T, error)) Wait() ([]T, error) }, handler func(string) (T, error)) ([]T, error)
For use with conc.ResultErrorPool
func RunOnResultPool ¶
func RunOnResultPool[T any](work <-chan string, completed chan<- string, pool interface { Go(func() T) Wait() []T }, handler func(string) T) []T
For use with conc.ResultPool
func Start ¶
Starts a scheduler for the tasks in the task set.
Names of tasks ready to be executed are sent to the returned start channel. On completion of a task, its name must be sent to the done channel.
Tasks will only be scheduled concurrently with other tasks in the same group. This also applies to the default group indicated by an empty group name.
The scheduler closes the start channel on exit. It will exit on completion of all tasks, or if no further tasks are schedulable (i.e. there is a deadlock), or if the done channel is closed.
Types ¶
type TaskSet ¶
type TaskSet struct {
// contains filtered or unexported fields
}