async

package
v0.0.0-...-ad8c3e4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package async is async/await pattern instrument based on golang typed parameters (generics). See https://medium.com/@jon_43067/go-generics-and-concurrency-d0dccab73a73

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Await

func Await(waiters ...Waiter) error

Types

type CancelingWaiter

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

func NewCancelingWaiter

func NewCancelingWaiter(ctx context.Context) (context.Context, *CancelingWaiter)

func (*CancelingWaiter) Await

func (w *CancelingWaiter) Await(waiters ...Waiter) error

type Func

type Func[In, Out any] func(context.Context, In) (Out, error)

func WithCancel

func WithCancel[In, Out any](f Func[In, Out]) Func[In, Out]

type Promise

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

func Go

func Go[In, Out any](ctx context.Context, f Func[In, Out], input In) *Promise[Out]

func Then

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

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