tokio/runtime/scheduler/
block_in_place.rs

1use crate::runtime::scheduler;
2
3#[track_caller]
4pub(crate) fn block_in_place<F, R>(f: F) -> R
5where
6    F: FnOnce() -> R,
7{
8    #[cfg(tokio_unstable)]
9    {
10        use crate::runtime::{Handle, RuntimeFlavor::MultiThreadAlt};
11
12        match Handle::try_current().map(|h| h.runtime_flavor()) {
13            Ok(MultiThreadAlt) => {
14                return scheduler::multi_thread_alt::block_in_place(f);
15            }
16            _ => {}
17        }
18    }
19
20    scheduler::multi_thread::block_in_place(f)
21}