promise

package
v0.18.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Promise

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

Promise is an asynchronous result to an operation.

func NewPromise

func NewPromise[T any]() *Promise[T]

NewPromise constructs a new empty Promise.

func NewPromiseWithErr

func NewPromiseWithErr[T any](err error) *Promise[T]

NewPromiseWithErr constructs a promise pre-resolved with an error.

func NewPromiseWithResult

func NewPromiseWithResult[T any](val T, err error) *Promise[T]

NewPromiseWithResult constructs a promise pre-resolved with a result.

func (*Promise[T]) Await

func (p *Promise[T]) Await(ctx context.Context) (val T, err error)

Await waits for the result to be set or for ctx to be canceled.

func (*Promise[T]) SetResult

func (p *Promise[T]) SetResult(val T, err error) bool

SetResult sets the result of the promise.

Returns false if the result was already set.

Jump to

Keyboard shortcuts

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