runtime.rs 720 B

1234567891011121314151617181920212223242526
  1. use std::{io, thread};
  2. use tokio::runtime;
  3. pub type FlowyRuntime = tokio::runtime::Runtime;
  4. pub fn tokio_default_runtime() -> io::Result<FlowyRuntime> {
  5. runtime::Builder::new_multi_thread()
  6. .thread_name("dispatch-rt")
  7. .enable_io()
  8. .enable_time()
  9. .on_thread_start(move || {
  10. tracing::trace!(
  11. "{:?} thread started: thread_id= {}",
  12. thread::current(),
  13. thread_id::get()
  14. );
  15. })
  16. .on_thread_stop(move || {
  17. tracing::trace!(
  18. "{:?} thread stopping: thread_id= {}",
  19. thread::current(),
  20. thread_id::get(),
  21. );
  22. })
  23. .build()
  24. }