From f03b3ba785a6d336884bfc525046906f8c2a9904 Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Mon, 5 Oct 2020 08:16:15 -0700 Subject: Import tokio-0.2.22 Test: None Change-Id: Iea7ee5e62819c9b16dbfad05a6146775df72506a --- src/runtime/blocking/mod.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/runtime/blocking/mod.rs (limited to 'src/runtime/blocking/mod.rs') diff --git a/src/runtime/blocking/mod.rs b/src/runtime/blocking/mod.rs new file mode 100644 index 0000000..0b36a75 --- /dev/null +++ b/src/runtime/blocking/mod.rs @@ -0,0 +1,43 @@ +//! Abstracts out the APIs necessary to `Runtime` for integrating the blocking +//! pool. When the `blocking` feature flag is **not** enabled, these APIs are +//! shells. This isolates the complexity of dealing with conditional +//! compilation. + +cfg_blocking_impl! { + mod pool; + pub(crate) use pool::{spawn_blocking, try_spawn_blocking, BlockingPool, Spawner}; + + mod schedule; + mod shutdown; + pub(crate) mod task; + + use crate::runtime::Builder; + + pub(crate) fn create_blocking_pool(builder: &Builder, thread_cap: usize) -> BlockingPool { + BlockingPool::new(builder, thread_cap) + + } +} + +cfg_not_blocking_impl! { + use crate::runtime::Builder; + use std::time::Duration; + + #[derive(Debug, Clone)] + pub(crate) struct BlockingPool {} + + pub(crate) use BlockingPool as Spawner; + + pub(crate) fn create_blocking_pool(_builder: &Builder, _thread_cap: usize) -> BlockingPool { + BlockingPool {} + } + + impl BlockingPool { + pub(crate) fn spawner(&self) -> &BlockingPool { + self + } + + pub(crate) fn shutdown(&mut self, _duration: Option) { + } + } +} -- cgit v1.2.3