-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: add sync.Future #17483
Comments
It seems that all of this can be implemented as an independent library It is not immediately obvious how one would implement "early collected by On Mon, Oct 17, 2016 at 1:04 PM, Sokolov Yura notifications@github.com
|
Reading the original proposal, honestly you made no valid arguments on why this should even be a thing. Less than 20 LOCs and does the job just fine, https://play.golang.org/p/PmMEGXaawH |
@OneOfOne neither your "future" could be used in |
That is why it should be a thing:
I thought "future" is very convenient concurrent primitive. Should I close this proposal? (I cannot close #17466 cause it is locked) |
As a general rule, as @RLH said above, the way to start something like this is to write an external library. If that seems to work well we can consider adopting it in the Go standard library. I'm going to close this proposal for now, but feel free to ping it again if you have an external library that people are adopting. |
What about #17466 ? Looks like it also has no chances. |
"future" is well known useful concurrency primitive.
So it strangely missed from language and standard library.
Since #17466 (add to language) doubtfully will be accepted, may be it is possible to add it to stdlib.
Proposal
add sync.Future with following properties:
select
statement,As additional properties:
As example implementation (but not final) I suggest following:
https://github.com/funny-falcon/go-datastructures/blob/future_selectable_lazy_chan/futures/selectable.go
Pros:
GetResult
on already filled future,Fill
, pointer to channel is changed to single global closed chan, so per Future channel could be early collected by GC (or even not allocated at all)The text was updated successfully, but these errors were encountered: