feldera_storage/
tokio.rs

1use once_cell::sync::Lazy;
2use tokio::runtime::{Builder, Runtime};
3
4/// The process running dbsp can share a single Tokio runtime.
5///
6/// This is `pub` so it can be used in dbsp and adapters too for IO.
7pub static TOKIO: Lazy<Runtime> = Lazy::new(|| {
8    Builder::new_multi_thread()
9        .thread_name_fn(|| {
10            use std::sync::atomic::{AtomicUsize, Ordering};
11            static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
12            let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst);
13            format!("feldera-tokio-{}", id)
14        })
15        .thread_stack_size(6 * 1024 * 1024)
16        .enable_all()
17        .build()
18        .unwrap()
19});