-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Change how task::future_result works #3725
Comments
There isn't presently a mechanism for atexit handlers, which would be required to do it the way the comment suggests. Alternatively the notify_port could just be replaced with a list of notify_ports. Either way, seems useful to enable multiple tasks futuring on a single task's exit. |
I think the approach in that comment is obsolete with pipes. Now I prefer changing the task notification to a |
And of course the callback interface of |
Having multiple tasks wait on a single condition is the "condition variable" model (cond-wait/cond-broadcast) -- we have condvars, but they are in libstd. They are just implemented with a list of oneshots, though, so I think having a list of notify_ |
(re: callback interface) yeah, I wasn't happy with that at all. that was the one thing the builder interface did better. |
That is not how I was thinking SharedOneShot would work. Maybe that's not the right name, since it isn't the same as SharedChan. I want a shared object that, the first time it is waited on performs the recieve, and subsequent times just looks at the value. Maybe a better composition would be some kind of |
This is similar to the problem with sharing futures of images in servo. Somebody has to receive the value the first time, then everybody else becomes a reader. |
Oh, right, and all other waiting tasks instead wait at the boundary of the MutexARC (which uses pipes internally). Sure. Also has the advantage of not needing to add new machinery and also not needing to call future_result at spawn-time multiple times (instead you can call clone() whenever you want). |
Visited for bug-triage, 2012jun24. Comment still exists in libstd/task/mod.rs. (And of course, brian's comment above indicates that he would prefer approach via pipes; I'm guessing until that is done, it is best to leave the comment in place as is, so people can see the dialogue here.) |
Triage: still a problem. |
The readme is still there. Should this remain, @alexcrichton? Seems... mostly obsolete? |
Hm, this doesn't quite make sense to me. The Nominating for removal from the 1.0 milestone because I think that this should be taken care of with stability attributes instead. |
Is the current alternative to somehow use |
We're going to leave it as is, on the 1.0 milestone. |
Nominating for removal from milestone. future_result is sane enough now that it's not the end of the world to be stuck with it forever (it used to require capturing in- and moving back out of a closure). I still would rather this be a |
@brson Just a heads-up: I have a patch in progress that revamps the task spawning API along exactly the lines you're suggesting, among other things. (I was waiting for librustrt to land before completing this.) +1 on milestone removal. |
Removing from milestone. We are trying to systemically review our libraries and mark them with stabilty attributes as appropriate. Leaving as P-backcompat-libs in hopes that it will be caught when all such tagged issues are reviewed. |
This patch consolidates and cleans up the task spawning APIs: * Removes the problematic `future_result` method from `std::task::TaskBuilder`, and adds a `try_future` that both spawns the task and returns a future representing its eventual result (or failure). * Removes the public `opts` field from `TaskBuilder`, instead adding appropriate builder methods to configure the task. * Adds extension traits to libgreen and libnative that add methods to `TaskBuilder` for spawning the task as a green or native thread. Previously, there was no way to benefit from the `TaskBuilder` functionality and also set the scheduler to spawn within. With this change, all task spawning scenarios are supported through the `TaskBuilder` interface. Closes rust-lang#3725. [breaking-change]
A FIXME note said "Once linked failure and notification are
// handled in the library, I can imagine implementing this by just
// registering an arbitrary number of task::on_exit handlers and
// sending out messages." The bugs this referred to are closed, so nothing's blocking this.
The text was updated successfully, but these errors were encountered: