File: counter.go

package info (click to toggle)
gitlab-shell 14.35.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,652 kB
  • sloc: ruby: 1,129; makefile: 583; sql: 391; sh: 384
file content (25 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (5)
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()
}