bronzeflow_core/executor/
tokio_executor.rs

1use crate::executor::Executor;
2use crate::runtime::tokio_runtime::TokioRuntime;
3use crate::runtime::{BronzeRuntime, Runnable};
4use std::sync::Arc;
5
6pub struct TokioExecutor {
7    runtime: Arc<TokioRuntime>,
8}
9
10impl TokioExecutor {
11    pub fn new(runtime: Arc<TokioRuntime>) -> Self {
12        TokioExecutor { runtime }
13    }
14}
15
16impl Executor for TokioExecutor {
17    #[inline(always)]
18    fn submit(&self, _: &mut impl Runnable, _: bool) {
19        // runnable.run();
20        // self.runtime.run_safe(runnable, report_msg);
21        panic!("not supported submit in `TokioExecutor`")
22    }
23    #[inline(always)]
24    fn submit_safe<F>(&self, runnable: F, report_msg: bool)
25    where
26        F: Runnable + Send + Sync + 'static,
27    {
28        self.runtime.run_safe(runnable, report_msg);
29    }
30
31    #[inline(always)]
32    fn support_async(&self) -> bool {
33        true
34    }
35}