track

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDying = errors.New("track: dying")

ErrDying is the error returned by Context.Err when the context is canceled.

Functions

This section is empty.

Types

type Context

type Context interface {
	// Done returns a channel that's closed when work done on behalf of this
	// context should be closed. Successive calls to Done return the same value.
	// The close of the Done channel may happen asynchronously after the close or
	// cancel function called.
	// a Done channel for cancellation.
	Done() <-chan struct{}
	// Err returns the err for the goroutine death provided via Close
	// If Done is not yet closed, Err returns nil.
	// If Done is closed, Err returns ErrDying.
	// If Done is closed with Cancel function, Err returns custom error.
	Err() error
	// Close flags the goroutine as dying.
	Close() error
	// Cancel flags the goroutine as dying with custom error.
	// if error is nil, it will use ErrDying.
	Cancel(err error) error
}

Context Context's methods may be called by multiple goroutines simultaneously.

type Track

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

Track tracks the lifecycle of a goroutine as alive, dying.

func (*Track) Cancel

func (sf *Track) Cancel(err error) error

Cancel flags the goroutine as dying with custom error. if error is nil, it will use ErrDying.

func (*Track) Close

func (sf *Track) Close() error

Close flags the goroutine as dying.

func (*Track) Done

func (sf *Track) Done() chan struct{}

Done a Done channel for cancellation.

func (*Track) Err

func (sf *Track) Err() error

Err returns the err for the goroutine death provided via Close If Done is not yet closed, Err returns nil. If Done is closed, Err returns ErrDying.

Jump to

Keyboard shortcuts

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