run

package
v11.4.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package run implements the "plz run" command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parallel

func Parallel(state *core.BuildState, labels []core.BuildLabel, args []string, numTasks int, quiet, env bool) int

Parallel runs a series of targets in parallel. Returns true if all were successful.

func Run

func Run(state *core.BuildState, label core.BuildLabel, args []string, env bool)

Run implements the running part of 'plz run'.

func Sequential

func Sequential(state *core.BuildState, labels []core.BuildLabel, args []string, quiet, env bool) int

Sequential runs a series of targets sequentially. Returns true if all were successful.

Types

type GoroutinePool

type GoroutinePool struct {
	// contains filtered or unexported fields
}

A GoroutinePool manages a set of worker goroutines, analogous to a traditional threadpool. Obviously in classic Go you do not need one, but this can be useful when you have external resources being driven by it that can't scale like goroutines (for example processes)

func NewGoroutinePool

func NewGoroutinePool(capacity int) *GoroutinePool

NewGoroutinePool allocates a new goroutine pool with the given maximum capacity (i.e. number of goroutines).

func (*GoroutinePool) Submit

func (pool *GoroutinePool) Submit(f func())

Submit submits a new work unit to the pool. It will be handled once a worker is free. Note that we only accept a niladic function, and do not provide an indication of when it completes, so you would typically wrap the call you want in an anonymous function, i.e.

var wg sync.WaitGroup
wg.Add(1)
pool.Submit(func() {
    callMyRealFunction(someParam)
    wg.Done()
})
wg.Wait()

Hint: ensure you are careful about closing over loop variables, Go closes over them by

reference not value so you may need to wrap them again (or use SubmitParam instead).

No particular guarantee is made about whether this function will block or not.

func (*GoroutinePool) SubmitParam

func (pool *GoroutinePool) SubmitParam(f func(interface{}), p interface{})

SubmitParam is similar to Submit but allows submitting a single parameter with the function. This is often convenient to close over loop variables etc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL