waitctx

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Restrictive = restrictive{}
	Permissive  = permissive{}

	AddOne          = Restrictive.AddOne
	Done            = Restrictive.Done
	Wait            = Restrictive.Wait
	WaitWithTimeout = Restrictive.WaitWWithTimeout
	Go              = Restrictive.Go
)

Functions

func Background

func Background() context.Context

func FromContext

func FromContext(ctx context.Context) context.Context

func RecoverTimeout added in v0.6.0

func RecoverTimeout()

Types

type PermissiveContext

type PermissiveContext = context.Context

type RestrictiveContext

type RestrictiveContext = context.Context

type WaitContextInterface

type WaitContextInterface interface {
	AddOne(ctx context.Context)
	Done(ctx context.Context)
	Wait(ctx context.Context, notifyAfter ...time.Duration)

	// Go runs the given function in a background goroutine, and adds it to the
	// WaitContext. Shorthand for the following pattern:
	//  waitctx.AddOne(ctx)
	//  go func() {
	//    defer waitctx.Done(ctx)
	//    // do stuff
	//  }()
	Go(ctx context.Context, fn func())
}

Jump to

Keyboard shortcuts

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