-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
task: Add more tips + links to spawn_blocking
docs
#4150
Conversation
f06a068
to
0f7b2cf
Compare
The CI failure is because your PR is written on top of an old master from May. |
OK I updated this and also added a link to the result from #4146 - so marking draft until that merges. |
0f7b2cf
to
e2d1642
Compare
I'm working on some code which heavily uses `spawn_blocking` to run synchronous code, and it took me a while to find and understand the relevant APIs and patterns here. First, basically no real world case will spawn a closure that takes no parameters, so change the first example to pass an input value, mutate it, and receive the result. Let's link to the channel blocking APIs, and provide a small example of that too. This also mentions `SyncIoBridge` now.
e2d1642
to
0bacb79
Compare
OK rebased 🏄 and now links to the SyncIOBridge from #4146 Specifically related to this subthread - I would say that the existing bridging toplevel doc is actually mostly about the inverse case of creating a tokio runtime for a portion of a largely synchronous codebase, whereas the goal of this PR is to help explain how to use some synchronous code inside a largely asynchronous codebase. I created tokio-rs/website#621 to link back to this one. |
I'm working on some code which heavily uses
spawn_blocking
to run synchronous code, and it took me a while to find and understand
the relevant APIs and patterns here.
First, basically no real world case will spawn
a closure that takes no parameters, so
change the first example to pass an input value, mutate it, and
receive the result.
Let's link to the channel blocking APIs, and provide a small example
of that too.
This also mentions
SyncIoBridge
now.