Documentation ¶
Overview ¶
Package parallel can be used for easily running goroutines with a limit on concurrency. It also helps with collecting errors.
It is intended as a replacement for github.com/rogpeppe/rog-go/parallel and avoids messing up CPU and memory profiles by not adding its own stack frame.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
Run represents a number of functions running concurrently.
func NewRun ¶
NewRun returns a new parallel instance. It will allow up to maxPar locks concurrently.
func (*Run) Acquire ¶
func (r *Run) Acquire()
Acquire acquires a lock. Up to maxPar (see NewRun) locks can be held concurrently. If no lock is available, Acquire blocks until another goroutine calls Release.
Caution: Call this before starting a new goroutine, not inside of it (race condition with Wait).