AppFlowy/frontend/rust-lib/lib-dispatch/src/runtime.rs
Nathan.fooo 6bb1c4e89c
feat: run rustfmt with custom defined fmt configuration (#1848)
* chore: update rustfmt

* chore: apply rustfmt format
2023-02-13 09:29:49 +08:00

27 lines
620 B
Rust

use std::{io, thread};
use tokio::runtime;
pub type AFPluginRuntime = tokio::runtime::Runtime;
pub fn tokio_default_runtime() -> io::Result<AFPluginRuntime> {
runtime::Builder::new_multi_thread()
.thread_name("dispatch-rt")
.enable_io()
.enable_time()
.on_thread_start(move || {
tracing::trace!(
"{:?} thread started: thread_id= {}",
thread::current(),
thread_id::get()
);
})
.on_thread_stop(move || {
tracing::trace!(
"{:?} thread stopping: thread_id= {}",
thread::current(),
thread_id::get(),
);
})
.build()
}