feat: add TokioTaskExecutor::boxed (#12619)

This commit is contained in:
Matthias Seitz
2024-11-18 12:47:30 +01:00
committed by GitHub
parent 1acdf9b2d4
commit 8aaac6d7c2

View File

@ -111,6 +111,13 @@ dyn_clone::clone_trait_object!(TaskSpawner);
#[non_exhaustive]
pub struct TokioTaskExecutor;
impl TokioTaskExecutor {
/// Converts the instance to a boxed [`TaskSpawner`].
pub fn boxed(self) -> Box<dyn TaskSpawner> {
Box::new(self)
}
}
impl TaskSpawner for TokioTaskExecutor {
fn spawn(&self, fut: BoxFuture<'static, ()>) -> JoinHandle<()> {
tokio::task::spawn(fut)