cancel

package
v0.15.4 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context) (*Context, *Source)

NewContext creates a new cancellation context and source parented to the given context. The returned cancellation context will be terminated when the supplied root context is canceled.

Types

type Context

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

Context provides the ability to observe cancellation and termination requests from a Source. A termination request automatically triggers a corresponding cancellation request. This can be used to implement cancellation with two priority levels.

func (*Context) CancelErr

func (c *Context) CancelErr() error

CancelErr returns a non-nil error iff the context has been canceled or terminated.

func (*Context) Canceled

func (c *Context) Canceled() <-chan struct{}

Canceled returns a channel that will be closed when the context is canceled or terminated.

func (*Context) TerminateErr

func (c *Context) TerminateErr() error

TerminateErr returns a non-nil error iff the context has been terminated.

func (*Context) Terminated

func (c *Context) Terminated() <-chan struct{}

Terminated returns a channel that will be closed when the context is terminated.

type Source

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

Source provides the ability to deliver cancellation and termination requests to a Context. A termination request automatically triggers a corresponding cancellation request. This can be used to implement cancellation with two priority levels.

func (*Source) Cancel

func (s *Source) Cancel()

Cancel cancels this source's context.

func (*Source) Context

func (s *Source) Context() *Context

Context returns the Context to which this source will deliver cancellation and termination requests.

func (*Source) Terminate

func (s *Source) Terminate()

Terminate terminates this source's context (which also cancels this context).

Jump to

Keyboard shortcuts

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