2022-06-27 15:15:43 +00:00
|
|
|
use std::{io, thread};
|
|
|
|
use tokio::runtime;
|
|
|
|
|
2022-12-01 00:35:50 +00:00
|
|
|
pub type AFPluginRuntime = tokio::runtime::Runtime;
|
2022-06-27 15:15:43 +00:00
|
|
|
|
2022-12-01 00:35:50 +00:00
|
|
|
pub fn tokio_default_runtime() -> io::Result<AFPluginRuntime> {
|
2023-02-13 01:29:49 +00:00
|
|
|
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()
|
2022-06-27 15:15:43 +00:00
|
|
|
}
|