2022-01-28 18:24:07 +07:00
|
|
|
//! A `ThreadPool` backend.
|
2020-01-20 04:47:36 +01:00
|
|
|
|
2022-01-28 18:24:07 +07:00
|
|
|
/// A thread pool executor for futures.
|
2022-02-01 11:40:58 +07:00
|
|
|
pub type Executor = futures::executor::ThreadPool;
|
2020-01-20 04:47:36 +01:00
|
|
|
|
2022-02-01 11:40:58 +07:00
|
|
|
impl crate::Executor for Executor {
|
2020-01-20 04:47:36 +01:00
|
|
|
fn new() -> Result<Self, futures::io::Error> {
|
|
|
|
|
futures::executor::ThreadPool::new()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn spawn(&self, future: impl Future<Output = ()> + Send + 'static) {
|
|
|
|
|
self.spawn_ok(future);
|
|
|
|
|
}
|
2025-04-02 20:33:22 +02:00
|
|
|
|
|
|
|
|
fn block_on<T>(&self, future: impl Future<Output = T>) -> T {
|
|
|
|
|
futures::executor::block_on(future)
|
|
|
|
|
}
|
2020-01-20 04:47:36 +01:00
|
|
|
}
|
2022-02-01 11:40:58 +07:00
|
|
|
|
|
|
|
|
pub mod time {
|
|
|
|
|
//! Listen and react to time.
|
|
|
|
|
}
|