feat(rt/tokio): introduce TokioLocalExecutor - #330
Merged
Merged
Conversation
cratelyn
marked this pull request as ready for review
September 28, 2026 21:18
2 tasks done
cratelyn
commented
Sep 29, 2026
cratelyn
force-pushed
the
kate/local-set-executor
branch
from
September 29, 2026 22:23
0848b37 to
4088d9c
Compare
LocalSetExecutorLocalExecutor
cratelyn
force-pushed
the
kate/local-set-executor
branch
from
September 29, 2026 22:26
4088d9c to
f28684e
Compare
this commit moves `rt::tokio::TokioExecutor` down a level into a new private `rt::tokio::executor` submodule. a `pub use` statement is placed into `rt::tokio` so that this retains an identical public interface. Signed-off-by: katelyn martin <git@katelyn.world>
cratelyn
force-pushed
the
kate/local-set-executor
branch
from
September 29, 2026 22:28
f28684e to
3422bd3
Compare
the `rt::tokio::TokioExecutor` type allows for hyper clients and servers to be run within a tokio runtime, and generally satisfies for most common use cases. however, `tokio::spawn()` has a trait bound that is not satisfiable in some cases: it mandates that spawned futures be `Send`. some asynchronous applications are not designed to permit work-stealing between threads, and expect that a spawned future be polled to completion on the same thread that spawned it. in order to facilitate such uses, this commit proposes the introduction of another `Executor` implementation. this commit introduces `LocalExecutor`, which makes use of `tokio::task::spawn_local()` rather than `tokio::task::spawn()` to spawn background tasks. two test cases showing that this can run a future that interacts with single-threaded reference counting storage (`Rc<T>`) is included to confirm that this works as expected, with both `LocalSet` and `LocalRuntime`. Signed-off-by: katelyn martin <git@katelyn.world>
cratelyn
force-pushed
the
kate/local-set-executor
branch
from
September 29, 2026 22:55
3422bd3 to
dc1b313
Compare
seanmonstar
reviewed
Sep 30, 2026
<hyperium#330 (comment)> to avoid conflicts with potential future additions integrating with other asynchronous runtimes, this commit adds a `Tokio` prefix to the name of our local task executor. Signed-off-by: katelyn martin <git@katelyn.world>
LocalExecutorTokioLocalExecutor
seanmonstar
approved these changes
Sep 30, 2026
This file contains hidden or 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
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.
the
rt::tokio::TokioExecutortype allows for hyper clients and servers to be run within a tokio runtime, and generally satisfies most common use cases.however,
tokio::spawn()has a trait bound that is not satisfiable in some cases: it mandates that spawned futures beSend. some asynchronous applications are not designed to permit work-stealing between threads, and expect that a spawned future be polled to completion on the same thread that spawned it.in order to facilitate such uses, this commit proposes the introduction of another
Executorimplementation. this commit introducesLocalSetExecutor, which makes use oftokio::task::spawn_local()rather thantokio::task::spawn()to spawn background tasks.a test case showing that this can run a future that interacts with single-threaded reference counting storage (
Rc<T>) is included to confirm that this works as expected.