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
v0.1.x: allow overriding blocking behavior #1752
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
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
this makes the new API totally safe :)
jonhoo
reviewed
Nov 7, 2019
// type to `Blocking::run_blocking`, we pass a _new_ closure which | ||
// doesn't have a return value. That closure invokes the blocking | ||
// function and assigns its value to `ret`, which we then unpack when | ||
// the blocking call finishes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes. This is the reason why the 0.2 version doesn't actually move the f
anywhere, and instead executes it directly in the in_place
function. I wonder if we could do something similar here.. But that may be too large a change to worry about it.
jonhoo
approved these changes
Nov 7, 2019
as per @carllerche's suggestion Signed-off-by: Eliza Weisman <eliza@buoyant.io>
hawkw
added a commit
that referenced
this pull request
Dec 3, 2019
0.1.17 (December 3, 2019) Added - Internal APIs for overriding blocking behavior (#1752) Signed-off-by: Eliza Weisman <eliza@buoyant.io>
carllerche
pushed a commit
that referenced
this pull request
Dec 4, 2019
0.1.17 (December 3, 2019) Added - Internal APIs for overriding blocking behavior (#1752) Signed-off-by: Eliza Weisman <eliza@buoyant.io>
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.
Motivation
The initial version of
tokio-compat
's compatibility runtime added in#1663 doesn't support the calls to
tokio_threadpool
0.1'sblocking
.This is because (unlike the timer, executor, and reactor), there's no
way to override the global
blocking
functionality intokio-threadpool
.Solution
As discussed here, this branch adds APIs to the v0.1.x version of
tokio-threadpool
that allow overriding the behavior used by calls toblocking
. The threadpool crate now exposesblocking::set_default
andblocking::with_default
functions, likeexecutor
,timer
, andreactor
. This will allowtokio-compat
to override calls to 0.1'sblocking
to use the newtokio
0.2 blocking APIs.Unlike the similar APIs in
executor
,timer
, andreactor
, the hooksfor overriding blocking behaviour are
#[doc(hidden)]
and have commentswarning against their use outside of
tokio-compat
. In general, thereprobably won't be a compelling reason to override these outside of the
compatibility layer.
Refs: #1722