contextutil

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 2 Imported by: 19

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