future

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCompositeFuture

func NewCompositeFuture[V any](ctx context.Context) (*CompositeFuture[V], CompositeFutureResolver[V])

func NewFuture

func NewFuture(ctx context.Context) (*Future, FutureResolver)

func NewValueFuture

func NewValueFuture[V any](ctx context.Context) (*ValueFuture[V], ValueFutureResolver[V])

Types

type CompositeFuture

type CompositeFuture[V any] struct {
	// contains filtered or unexported fields
}

func (*CompositeFuture[V]) Cancel added in v2.1.0

func (f *CompositeFuture[V]) Cancel(cause error)

func (*CompositeFuture[V]) Context added in v2.0.3

func (f *CompositeFuture[V]) Context() context.Context

func (*CompositeFuture[V]) Done added in v2.1.0

func (f *CompositeFuture[V]) Done(count int) <-chan struct{}

func (*CompositeFuture[V]) Wait added in v2.0.1

func (f *CompositeFuture[V]) Wait(count int) ([]V, error)

type CompositeFutureResolver

type CompositeFutureResolver[V any] func(index int, value V, err error)

type Future

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

A Future represents a value that will be available in the Future. It is always associated with a context that can be used to wait for the value to be available. When the parent context is canceled, the Future will be canceled as well.

func (*Future) Done

func (f *Future) Done() <-chan struct{}

func (*Future) Err

func (f *Future) Err() error

func (*Future) Wait

func (f *Future) Wait() error

Wait waits for the future to complete and returns any error that occurred.

type FutureResolver

type FutureResolver func(err error)

type ValueFuture

type ValueFuture[V any] struct {
	// contains filtered or unexported fields
}

A Future represents a value that will be available in the Future. It is always associated with a context that can be used to wait for the value to be available. When the parent context is canceled, the Future will be canceled as well.

func (*ValueFuture[V]) Done

func (f *ValueFuture[V]) Done() <-chan struct{}

func (*ValueFuture[V]) Result

func (f *ValueFuture[V]) Result() (V, error)

func (*ValueFuture[V]) Wait

func (f *ValueFuture[V]) Wait() (V, error)

Get waits for the future to complete and returns the output and any error that occurred.

type ValueFutureResolver

type ValueFutureResolver[V any] func(value V, err error)

Jump to

Keyboard shortcuts

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