Skip to content

feat(rt/tokio): introduce TokioHandleExecutor - #331

Merged
cratelyn merged 3 commits into
hyperium:masterfrom
cratelyn:kate/tokio-executors
Oct 2, 2026
Merged

cratelyn merged 3 commits into
hyperium:masterfrom
cratelyn:kate/tokio-executors

Conversation

@cratelyn

@cratelyn cratelyn commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

this commit introduces an hyper::rt::Executor implementation, HandleExecutor. this executor is used to run tasks on a tokio runtime, but spawns tasks onto a particular runtime using a provided tokio::runtime::Handle rather than by calling tokio::spawn()

this is useful for situations in which you wish to run tasks on a separate runtime, for example. this may be applicable to those configuring hyper clients and servers in applications running on NUMA (Non-Uniform Memory Awareneses) systems, or those that wish to manage provision separate resources for background tasks. see the tokio::runtime documentation for more information about choosing the correct runtime for an application.

a unit test is included which demonstrates that HandleExecutor can be used to spawn background tasks onto a separate tokio runtime.

this branch includes an update to the tokio dependency, bumping the verion from 1.13 to 1.49.

see: https://github.com/tokio-rs/tokio/blob/master/tokio/CHANGELOG.md#1490-january-3rd-2026

this does not break hyper-util's MSRV, this tokio release supports 1.71 and newer. this release includes the stabilization of tokio::runtime::Handle::id(), which permit us to write unit tests that inspect which runtime a spawned future is being run on.


@cratelyn cratelyn added C-feature Category: feature. This is adding a new feature. A-rt Area: runtime components. labels Sep 29, 2026
@cratelyn
cratelyn force-pushed the kate/tokio-executors branch 4 times, most recently from e1f4b08 to 058347d Compare September 29, 2026 22:28
@cratelyn
cratelyn marked this pull request as ready for review September 29, 2026 22:28
@cratelyn cratelyn self-assigned this Sep 29, 2026
@cratelyn
cratelyn requested a review from dswij September 29, 2026 22:47
@cratelyn
cratelyn marked this pull request as draft September 30, 2026 21:00
@cratelyn

Copy link
Copy Markdown
Member Author

rebasing now that #330 landed.

see: https://github.com/tokio-rs/tokio/blob/master/tokio/CHANGELOG.md#1490-january-3rd-2026

this does not break hyper-util's MSRV, this tokio release supports 1.71
and newer.

this release includes the stabilization of
`tokio::runtime::Handle::id()`, which will permit us to write unit tests
that inspect which runtime a spawned future is being run on.

Signed-off-by: katelyn martin <git@katelyn.world>
this commit introduces an `hyper::rt::Executor` implementation,
`TokioHandleExecutor`. this executor is used to run tasks on a tokio
runtime, but spawns tasks onto a particular runtime using a provided
`tokio::runtime::Handle` rather than by calling `tokio::spawn()`

this is useful for situations in which you wish to run tasks on a
*separate* runtime, for example. this may be applicable to those
configuring hyper clients and servers in applications running on NUMA
(Non-Uniform Memory Awareneses) systems, or those that wish to manage
provision separate resources for background tasks. see the
[`tokio::runtime`] documentation for more information about choosing the
correct runtime for an application.

a unit test is included which demonstrates that `TokioHandleExecutor`
can be used to spawn background tasks onto a separate tokio runtime.

[`tokio::runtime`]: https://docs.rs/tokio/latest/tokio/runtime/index.html#numa-awareness

Signed-off-by: katelyn martin <git@katelyn.world>
@cratelyn
cratelyn force-pushed the kate/tokio-executors branch from 058347d to eee3d23 Compare September 30, 2026 21:08
@cratelyn
cratelyn marked this pull request as ready for review September 30, 2026 21:13
@cratelyn cratelyn changed the title feat(rt/tokio): introduce HandleExecutor feat(rt/tokio): introduce TokioHandleExecutor Sep 30, 2026

@seanmonstar seanmonstar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. If you find there's a need, no problem.

@dswij dswij left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, looks great!

@cratelyn
cratelyn enabled auto-merge (squash) October 2, 2026 16:20
@cratelyn
cratelyn merged commit 3d99e03 into hyperium:master Oct 2, 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.

3 participants