mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
23 lines
486 B
Rust
23 lines
486 B
Rust
use std::future::Future;
|
|
|
|
use crate::{error::Error, io::scheduler::Scheduler};
|
|
|
|
/// Multi-threading with Tokio.
|
|
pub struct TokioScheduler;
|
|
|
|
impl TokioScheduler {
|
|
pub fn new() -> Self {
|
|
Self {}
|
|
}
|
|
}
|
|
|
|
impl Scheduler for TokioScheduler {
|
|
fn schedule<T>(&self, future_factory: impl FnOnce() -> T + Send + 'static) -> Result<(), Error>
|
|
where
|
|
T: Future<Output = ()> + Send + 'static,
|
|
{
|
|
tokio::task::spawn((future_factory)());
|
|
Ok(())
|
|
}
|
|
}
|