1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
package commandcounter
import "sync"
// inFlightCommands tracks the number of in-flight commands. This is hosted outside of the command
// package to avoid a cyclic dependency with the testhelper package.
var inFlightCommands = &sync.WaitGroup{}
// Increment will add another process to the command counter. This may only be called by the
// command package.
func Increment() {
inFlightCommands.Add(1)
}
// Decrement removes one process from the command counter. This may only be called by the command
// package.
func Decrement() {
inFlightCommands.Done()
}
// WaitAllDone waits for all commands started by the command package to finish. This can only be
// called once in the lifecycle of the current Go process.
func WaitAllDone() {
inFlightCommands.Wait()
}
|