Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertSpyWaitGroupNormalUsage ¶
func AssertSpyWaitGroupNormalUsage(t *testing.T, wg *SpyWaitGroup, threadCount int)
func Goid ¶
func Goid() int
Borrowed from: https://gist.github.com/metafeather/3615b23097836bc36579100dac376906
func IsPossiblyNegative ¶ added in v0.7.0
IsPossiblyNegative checks whether the integer could be a negative int32, unless its value is bigger than int32.max.
Types ¶
type SpyWaitGroup ¶
type SpyWaitGroup struct { Deltas []int DeltaGoids []int Awaited bool AwaitedByGoid int // contains filtered or unexported fields }
SpyWaitGroup provides an ability to assess whether the usage of the WaitGroup was correct. It records the sequence of calls as an array of deltas, arguments to the WaitGroup.Add() function. Additionally, it records the goid of the goroutines that performed the calls. SpyWaitGroup uses sync.WaitGroup under the hood and is thread-safe.
func (*SpyWaitGroup) Add ¶
func (wg *SpyWaitGroup) Add(delta int)
Add remembers the delta and the goid of caller and forwards the call to sync.WaitGroup.
func (*SpyWaitGroup) Wait ¶
func (wg *SpyWaitGroup) Wait()
Wait remembers the goid of the caller and sets Awaited to true. It consequently, calls sync.WaitGroup.Wait().