Skip to content
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

Be more principled about when blocking is ok #2410

Merged
merged 4 commits into from
Apr 20, 2020
Merged

Conversation

jonhoo
Copy link
Sponsor Contributor

@jonhoo jonhoo commented Apr 16, 2020

This enables block_in_place to be used in more contexts. Specifically,
it allows you to block whenever you are off the tokio runtime (like if
you are not using tokio, are in a spawn_blocking closure, etc.), and
in the threaded scheduler's block_on. Blocking in LocalSet and the
basic scheduler's block_on is still disallowed.

Fixes #2327.
Fixes #2393.

This enables `block_in_place` to be used in more contexts. Specifically,
it allows you to block whenever you are off the tokio runtime (like if
you are not using tokio, are in a `spawn_blocking` closure, etc.), and
in the threaded scheduler's `block_on`. Blocking in `LocalSet` and the
basic scheduler's` block_on` is still disallowed.

Fixes #2327.
@jonhoo jonhoo added C-enhancement Category: A PR with an enhancement or bugfix. finish-line A-tokio Area: The main tokio crate M-blocking Module: tokio/task/blocking S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed E-finish-line labels Apr 17, 2020
@jonhoo jonhoo merged commit 282b00c into master Apr 20, 2020
@jonhoo jonhoo deleted the more-block-in-place branch April 20, 2020 23:18
@Darksonn Darksonn removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 21, 2020
jonhoo added a commit to mit-pdos/noria that referenced this pull request Apr 25, 2020
@Darksonn Darksonn removed the relnotes label Apr 29, 2020
jgrund added a commit to jgrund/tokio-diesel that referenced this pull request May 20, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

Fixes mehcode#9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
jgrund added a commit to jgrund/tokio-diesel that referenced this pull request May 20, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

Fixes mehcode#9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
jgrund added a commit to jgrund/tokio-diesel that referenced this pull request May 20, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

Fixes mehcode#9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
jgrund added a commit to jgrund/tokio-diesel that referenced this pull request May 20, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

Fixes mehcode#9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
jgrund added a commit to jgrund/tokio-diesel that referenced this pull request May 20, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

Fixes mehcode#9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
jgrund added a commit to jgrund/tokio-diesel that referenced this pull request May 20, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

Fixes mehcode#9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
jgrund added a commit to jgrund/tokio-diesel that referenced this pull request May 20, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

Fixes mehcode#9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
jgrund added a commit to jgrund/tokio-diesel that referenced this pull request May 20, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

I've also added in github actions to ensure this change works (and
continues to) :) .

Fixes mehcode#9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
mehcode pushed a commit to mehcode/tokio-diesel that referenced this pull request Jun 10, 2020
Use `task::block_in_place` with allows a number of `'static` lifetimes
to be removed.

This now works outside a task spawn due to
tokio-rs/tokio#2410 with the restriction that a
threaded runtime is used.

I've also added in github actions to ensure this change works (and
continues to) :) .

Fixes #9.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-blocking Module: tokio/task/blocking
Projects
None yet
3 participants