Skip to content

Instantly share code, notes, and snippets.

@jonbodner
Created August 24, 2017 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonbodner/ef1d328c2906638c0bc7e6f569d6838f to your computer and use it in GitHub Desktop.
Save jonbodner/ef1d328c2906638c0bc7e6f569d6838f to your computer and use it in GitHub Desktop.
future-blog-post-9
func main() {
a := 10
f := future.New(func() (interface{}, error) {
return doSomethingThatTakesAWhile(a)
})
// this will wait for a second to complete
// and will return nil for both val and err
// and timeout will be true
val, timeout, err := f.GetUntil(1 * time.Second)
fmt.Println(val, timeout, err)
// this will wait for val and err to have values
val, err = f.Get()
fmt.Println(val, err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment