sync_testing

package module
v0.0.0-...-575d6b3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2016 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Synchronous testing utilities.

License

This software is licensed under Apache License, Version 2.0. Please see LICENSE for more information.

Copyright© 2016, Flux Factory Inc.

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

func MaximizeContentionWithErrors(N int, f ...func() error) error

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.

Jump to

Keyboard shortcuts

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