Remove the 'static bound from everywhere #100
Open
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 enables big performance improvements by not having to clone elements for
ParallelStream
s.The complication is that, akin to
crossbeam::scope
, we need to block before returning to avoid the usermem::forget
ting the handle and mutating the data while other threads still have a reference to it. If we were sync (like for examplerayon
) this wouldn't be much of an issue. As we're async and have to return whenever I/O blocks, this is harder to deal with.The current compromise in this PR is using
tokio
to block the current task (when running under the multithreaded scheduler) or current thread (when running under the basic scheduler). This is unfortunately mildly surprising from a user POV. WIP.TODO:
ThreadPool::spawn
ed futures (e.g. during.all()
) to ack that they've been cancelled, to avoid returning while a task may be running on another thread that uses referenced dataSee also:
tokio-rs/tokio#1879 tokio-rs/tokio#2576 tokio-rs/tokio#2596 rust-lang/rfcs#2958 rmanoka/async-scoped
There are two issues:
JoinHandle::drop
we must block on this async cancellation. Prefer some sort of async drop as an optimisation to avoid the blocking.And a third: