Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaximizeContention ¶
func MaximizeContention(N int, f ...func())
MaximizeContention starts N goroutines, each performing one of the provided functions, and executes all of them as concurrently as possible. If 3 functions are provided, then each function is run N/3 times.
func MaximizeContentionWithErrors ¶
MaximizeContentionWithErrors operates identically to MaximizeContention but returns a multierror with all non-nil errors.
Types ¶
type ParallelOpTracker ¶
type ParallelOpTracker struct {
// contains filtered or unexported fields
}
ParallelOpTracker is a utility structure designed to help detect operations that execute in parallel. Typical usage is:
N := 1000 // approximate number of operations.
ops := NewParallelOpTracker(N)
ops.Do("sync-op") // never be done in parallel with other ops
MaximizeContention(N,
func() { ops.Do("something") }, // may be done in parallel
func() { ops.Do("other thing") }) // may be done in parallel
ops.Do("sync-op") // never be done in parallel with other ops
So(ops.During("sync-op"), ShouldNotContainKey, "something")
So(ops.During("sync-op"), ShouldNotContainKey, "other thing")
So(ops.During("sync-op"), ShouldNotContainKey, "sync-op")
func NewParallelOpTracker ¶
func NewParallelOpTracker(expectedNumOps int) *ParallelOpTracker
NewParallelOpTracker returns an initialized ParallelOpTracker for the approximate number of events.
func (*ParallelOpTracker) Do ¶
func (o *ParallelOpTracker) Do(op string)
Do performs an operation. All calls to Do() must be performed before any calls to Events() or During().
func (*ParallelOpTracker) During ¶
func (o *ParallelOpTracker) During(op string) map[string]int
During returns a map of events that occurred during a particular op.
func (*ParallelOpTracker) Events ¶
func (o *ParallelOpTracker) Events() []string
Events returns the ordered list of events that occurred.