futures

package
v0.0.0-...-11ada09 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFutureCanceled = errors.New("future canceled")

Functions

This section is empty.

Types

type Completer

type Completer <-chan interface{}

type Future

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

func New

func New(completer Completer, timeout time.Duration) *Future

func (*Future) GetResult

func (f *Future) GetResult() (interface{}, error)

GetResult will immediately fetch the result if it exists or wait on the result until it is ready.

func (*Future) HasResult

func (f *Future) HasResult() bool

HasResult will return true iff the result exists

type Selectable

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

func NewSelectable

func NewSelectable() *Selectable

func (*Selectable) Cancel

func (f *Selectable) Cancel()

Cancel is alias for SetError(ErrFutureCanceled)

func (*Selectable) Fill

func (f *Selectable) Fill(v interface{}, e error) error

Fill sets value for future, if it were not already fullfilled Returns error, if it were already set to future.

func (*Selectable) GetResult

func (f *Selectable) GetResult() (interface{}, error)

GetResult waits for future to be fullfilled and returns value or error, whatever is set first

func (*Selectable) SetError

func (f *Selectable) SetError(e error)

func (*Selectable) SetValue

func (f *Selectable) SetValue(v interface{}) error

func (*Selectable) WaitChan

func (f *Selectable) WaitChan() <-chan struct{}

WaitChan returns channel, which is closed when future is fullfilled.

Jump to

Keyboard shortcuts

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