metacontext

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetaContext

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

MetaContext is an object which implements context.Context and which holds multiple contexts within it. The MetaContext is considered canceled only when ALL of the underlying contexts have been canceled.

Once canceled, it cannot be uncancelled, so it is an error to keep adding contexts once the meta context is considered cancelled.

func New

func New(ctx context.Context) *MetaContext

New returns a new metacontext.

func (*MetaContext) Add

func (mc *MetaContext) Add(ctx context.Context) error

Add adds a new context to the metacontext.

func (*MetaContext) Deadline

func (mc *MetaContext) Deadline() (deadline time.Time, ok bool)

Deadline returns the earliest Deadline in the pool.

func (*MetaContext) Done

func (mc *MetaContext) Done() <-chan struct{}

Done returns the done channel. The MetaContext is done only when ALL of the contained contexts are done.

func (*MetaContext) Err

func (mc *MetaContext) Err() error

Err returns the first done error reported by any context, if the whole context is done. Nil otherwise.

func (*MetaContext) Value

func (mc *MetaContext) Value(key interface{}) interface{}

Value calls context.Value on the first not-done context, or on the first one, if all are done.

Jump to

Keyboard shortcuts

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