Skip to content

feat(rt/tokio): introduce TokioLocalExecutor - #330

Merged
cratelyn merged 3 commits into
hyperium:masterfrom
cratelyn:kate/local-set-executor
Sep 30, 2026
Merged

cratelyn merged 3 commits into
hyperium:masterfrom
cratelyn:kate/local-set-executor

Conversation

@cratelyn

@cratelyn cratelyn commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

the rt::tokio::TokioExecutor type 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 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 LocalSetExecutor, which makes use of tokio::task::spawn_local() rather than tokio::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.


@cratelyn cratelyn self-assigned this Sep 28, 2026
@cratelyn cratelyn added C-feature Category: feature. This is adding a new feature. A-rt Area: runtime components. labels Sep 28, 2026
@cratelyn
cratelyn marked this pull request as ready for review September 28, 2026 21:18
Comment thread src/rt/tokio/executor.rs Outdated
@cratelyn
cratelyn force-pushed the kate/local-set-executor branch from 0848b37 to 4088d9c Compare September 29, 2026 22:23
@cratelyn cratelyn changed the title feat(rt/tokio): introduce LocalSetExecutor feat(rt/tokio): introduce LocalExecutor Sep 29, 2026
@cratelyn
cratelyn force-pushed the kate/local-set-executor branch from 4088d9c to f28684e Compare September 29, 2026 22:26
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
cratelyn force-pushed the kate/local-set-executor branch from f28684e to 3422bd3 Compare September 29, 2026 22:28
@cratelyn
cratelyn requested a review from dswij September 29, 2026 22:47
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
cratelyn force-pushed the kate/local-set-executor branch from 3422bd3 to dc1b313 Compare September 29, 2026 22:55
Comment thread src/rt/tokio/executor.rs Outdated
<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>
@cratelyn cratelyn changed the title feat(rt/tokio): introduce LocalExecutor feat(rt/tokio): introduce TokioLocalExecutor Sep 30, 2026
@cratelyn
cratelyn removed the request for review from dswij September 30, 2026 20:46
@cratelyn
cratelyn merged commit 5dd670a into hyperium:master Sep 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rt Area: runtime components. C-feature Category: feature. This is adding a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants