maplibre-rs/maplibre/src/platform/noweb/schedule_method.rs
2022-04-22 21:16:35 +02:00

21 lines
508 B
Rust

use crate::io::shared_thread_state::SharedThreadState;
pub struct TokioScheduleMethod;
impl TokioScheduleMethod {
pub fn new() -> Self {
Self {}
}
pub fn schedule<T>(
&self,
shared_thread_state: SharedThreadState,
future_factory: impl (FnOnce(SharedThreadState) -> T) + Send + 'static,
) where
T: std::future::Future + Send + 'static,
T::Output: Send + 'static,
{
tokio::task::spawn(future_factory(shared_thread_state));
}
}