future

package
v0.0.0-...-6da0beb Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2017 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Future

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

Future is a type that is essentially the inverse of a channel. With a channel, you have multiple senders and one receiver. With a future, you can have multiple receivers and one sender. Additionally, a future protects against double-sends. Since this is usually used for returning function results, we also capture and return error values as well. Use NewFuture to initialize.

func New

func New() *Future

NewFuture returns an initialized and ready Future.

func (*Future) Fired

func (self *Future) Fired() bool

Fired returns whether or not a value has been set. If Fired is true, Get won't block.

func (*Future) Get

func (self *Future) Get() (interface{}, error)

Get blocks until the Future has a value set.

func (*Future) Set

func (self *Future) Set(val interface{}, err error)

Set provides the value to present and future Get calls. If Set has already been called, this is a no-op.

Jump to

Keyboard shortcuts

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