Skip to content

Instantly share code, notes, and snippets.

@jonbodner
Last active August 24, 2017 17:01
Show Gist options
  • Save jonbodner/5f202cd9b98722239a9f1bc850238bfe to your computer and use it in GitHub Desktop.
Save jonbodner/5f202cd9b98722239a9f1bc850238bfe to your computer and use it in GitHub Desktop.
future-blog-post-6
// New creates a new Future that wraps the provided function.
func New(inFunc Processor) Interface {
f := &futureImpl {
done: make(chan struct{}),
}
go func() {
f.val, f.err = inFunc()
close(f.done)
}()
return f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment