1 | //! The runtime. |
2 | |
3 | use std::env; |
4 | |
5 | use once_cell::sync::Lazy; |
6 | |
7 | /// Dummy runtime struct. |
8 | pub struct Runtime {} |
9 | |
10 | /// The global runtime. |
11 | pub static RUNTIME: Lazy<Runtime> = Lazy::new(|| { |
12 | // Create an executor thread pool. |
13 | |
14 | let thread_name: String = env::var("ASYNC_STD_THREAD_NAME" ).unwrap_or_else(|_| "async-std/runtime" .to_string()); |
15 | async_global_executor::init_with_config(async_global_executor::GlobalExecutorConfig::default().with_env_var("ASYNC_STD_THREAD_COUNT" ).with_thread_name_fn(move || thread_name.clone())); |
16 | |
17 | Runtime {} |
18 | }); |
19 | |