Documentation
¶
Overview ¶
Package parallel shares a job of many tasks among the goroutines of a pool kept for the whole game: the caller's own and the pool's, each known by its number.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch is the tasks of one Begin; Add and Wait are its caller's.
type Forkable ¶
type Forkable[R any] interface { Fork() R }
Forkable reads state on one goroutine at a time: Fork is one more, for another.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is Size goroutines sharing the tasks of one Batch at a time: worker 0, the caller of Wait, and Size−1 of the pool's own, waiting between batches. Size and Parts take a nil Pool for one goroutine.
func New ¶
New is a pool of size goroutines, the caller's among them; 0 or less as many as there are CPUs.
func (*Pool) Begin ¶
Begin starts a batch: task(w, i) runs on worker w for every task i added; idle(w), if not nil, once on each worker the first time it finds no task left. Functions made once allocate nothing.