Skip to content

tokio::spawn should have task names #2645

Open
@Milo123459

Description

@Milo123459

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Using the console, it would be nice if hyper had some task names
Describe the solution you'd like
A clear and concise description of what you want to happen.
Implement a custom function for spawning something with a named parameter. Here is some code I wrote up:

pub fn spawn_named<T>(
	name: &str,
	future: impl std::future::Future<Output = T> + Send + 'static,
) -> tokio::task::JoinHandle<T>
where
	T: Send + 'static,
{
	#[cfg(tokio_unstable)]
	return tokio::task::Builder::new().name(name).spawn(future);

	#[cfg(not(tokio_unstable))]
	tokio::spawn(future)
}

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
N/A
Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-upstreamBlocked: needs a change in a dependency or the compiler.C-featureCategory: feature. This is adding a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions