open_entry_bindings/
executor.rs

1use std::{sync::Arc, any::Any, pin::Pin, future::Future};
2
3use fast_async_mutex::mutex::Mutex as SpinMutex;
4use tokio::sync::Mutex;
5
6use crate::{shutdown_type::ShutdownType, virtual_thread::VThread};
7
8pub enum ExecutorLock {
9    None,
10    Sys(Arc<Mutex<()>>),
11    Spin(Arc<SpinMutex<()>>),
12}
13
14impl ExecutorLock {
15    #[inline(always)] pub fn sys(&self) -> &Arc<Mutex<()>> {
16        unsafe { crate::ExecutorLock__sys.unwrap_unchecked()(self) }
17    }
18
19    #[inline(always)] pub fn spin(&self) -> &Arc<SpinMutex<()>> {
20        unsafe { crate::ExecutorLock__spin.unwrap_unchecked()(self) }
21    }
22}
23
24pub enum ExecutorBehaviour {
25    None,
26    Shutdown(ShutdownType)
27}
28
29pub type Lock = Option<Box<dyn Any + Send + Sync>>;
30
31// It isnt dead code huh
32#[allow(dead_code)] type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
33pub type Executor = Arc<dyn ExecutorFunc + Send + Sync>;
34
35pub trait ExecutorFunc {
36    fn call(&self, thread: VThread) -> BoxFuture<'static, ()>;
37}