promise

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wait

func Wait(ws ...Waiter) error

func WaitForAll

func WaitForAll[T any](promises []*Promise[T]) (err error)

Types

type Func

type Func[T, V any] func(context.Context, T) (V, error)

func WithCancellation

func WithCancellation[T, V any](f Func[T, V]) Func[T, V]

type Func2

type Func2[T, K, V any] func(context.Context, T, K) (V, error)

type MapFunc

type MapFunc[T, V any] func(T) V

type Promise

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

func MapAndThen

func MapAndThen[T, V, K any](ctx context.Context, p *Promise[T], mf MapFunc[T, K], f Func[K, V]) *Promise[V]

func NewPromise

func NewPromise[T, V any](ctx context.Context, t T, f Func[T, V]) *Promise[V]

func Then

func Then[T, V any](ctx context.Context, p *Promise[T], f Func[T, V]) *Promise[V]

func Zip

func Zip[T, K, V any](ctx context.Context, pt *Promise[T], pk *Promise[K], f Func2[T, K, V]) *Promise[V]

func (*Promise[V]) Get

func (p *Promise[V]) Get() (V, error)

func (*Promise[V]) Wait

func (p *Promise[V]) Wait() error

type Waiter

type Waiter interface {
	Wait() error
}

Jump to

Keyboard shortcuts

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