contextutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: CC0-1.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link interface {
	Stop() // Stop breaks the link.
}

Link is used to temporarily link a context with a cancel function.

func NewChannelLink(c <-chan struct{}, cancel context.CancelFunc) Link

NewChannelLink will temporarily link the given channel to the given cancel function: that is, the channel firing will cause the cancel function to be called. Call Stop on the returned Link to break the link; for example:

defer NewChannelLink(doneC, cancel).Stop()
func NewLink(ctx context.Context, cancel context.CancelFunc) Link

NewLink will temporarily link the given context to the given cancel function: that is, the context firing will cause the cancel function to be called. Call Stop on the returned Link to break the link; for example:

defer NewLink(ctx, cancel).Stop()

Jump to

Keyboard shortcuts

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