-
Notifications
You must be signed in to change notification settings - Fork 501
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
Support spawning asynchronous tasks #212
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@cuviper I'm planning to merge this after adding a few more tests. Last chance to complain. 👅 |
nikomatsakis
force-pushed
the
futures-async
branch
from
February 26, 2017 11:20
8f82b73
to
2af442e
Compare
nikomatsakis
changed the title
WIP: support spawning asynchronous tasks
Support spawning asynchronous tasks
Feb 26, 2017
For now, we abort in various anomalous scenarios. This is likely not the right default.
This fixes a latent bug in the splitting code for the parallel iterator, which would have grabbed the wrong number of threads if we were working inside a custom threadpool.
This will be useful when we permit spawning async jobs.
It is no longer dependent on scope, and instead serves a cross-cutting role.
The unsafe keyword was not needed, because the safety is implied by the unsafe trait `FutureScope`. The `future` module now re-exports the relevant parts of `futures` crate for convenience in the rest of Rayon.
nikomatsakis
force-pushed
the
futures-async
branch
from
February 26, 2017 11:23
2af442e
to
3d2f85c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the successor to #161. This branch adds support for two new top-level functions (there are also corresponding methods on
ThreadPool
):spawn_async()
-- executes aFnOnce()
for side-effects in the Rayon threadpool. LikeScope::spawn()
, but no scope is needed, and hence the closure must be'static
.spawn_future_async()
-- executes a future in the Rayon threadpool. LikeScope::spawn_future()
, but no scope is needed, and hence the future must be'static
.The use-case here is that sometimes you would like to have work that executes asynchronously from your main thread (so that you don't have to block for it). You'd prefer for that job to share a thread-pool with the rest of your parallel work. You can now use
spawn_async
for that purpose. @glennw encountered just such a scenario in Servo's texture cache. (I think?)WIP Aspects
There are a number of things I am not sure of where I would like feedback:
async
naming. It seems to suggestasync-await
. Perhapsdetach
would be better.spawn_async()
function.To Do Items
This isn't terribly polished but I wanted to bring it up to start getting some feedback.
spawn_future_async
-- pretty minimal right now.