Skip to content

Instantly share code, notes, and snippets.

@jonbodner
Last active August 24, 2017 17:01
Show Gist options
  • Save jonbodner/f4280094d6f5569fdfaec9c6ebb16516 to your computer and use it in GitHub Desktop.
Save jonbodner/f4280094d6f5569fdfaec9c6ebb16516 to your computer and use it in GitHub Desktop.
future-blog-post-7
// Interface represents a future. No concrete implementation is
// exposed; all access to a future is via this interface.
type Interface interface {
// Get returns the values calculated by the future. It will pause until
// the value is calculated.
//
// If Get is invoked multiple times, the same value will be returned each time.
// Subsequent calls to Get will return instantaneously.
Get() (interface{}, error)
// GetUntil waits for up to Duration d for the future to complete. If the
// future completes before the Duration completes, the value and error are returned
// and timeout is returned as false. If the Duration completes before the future
// returns, nil is returned for the value and the error and timeout is returned
// as true.
GetUntil(d time.Duration) (interface{}, bool, error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment