ctxwatch

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextWatcher

type ContextWatcher struct {
	// contains filtered or unexported fields
}

ContextWatcher watches a context and performs an action when the context is canceled. It can watch one context at a time.

func NewContextWatcher

func NewContextWatcher(onCancel func(), onUnwatchAfterCancel func()) *ContextWatcher

NewContextWatcher returns a ContextWatcher. onCancel will be called when a watched context is canceled. OnUnwatchAfterCancel will be called when Unwatch is called and the watched context had already been canceled and onCancel called.

func (*ContextWatcher) Unwatch

func (cw *ContextWatcher) Unwatch()

Unwatch stops watching the previously watched context. If the onCancel function passed to NewContextWatcher was called then onUnwatchAfterCancel will also be called.

func (*ContextWatcher) Watch

func (cw *ContextWatcher) Watch(ctx context.Context)

Watch starts watching ctx. If ctx is canceled then the onCancel function passed to NewContextWatcher will be called.

Jump to

Keyboard shortcuts

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