#[cfg(feature = "executor-interrupt")]
compile_error!("`executor-interrupt` is not supported with `platform-spin`.");
#[cfg(feature = "executor-thread")]
pub use thread::*;
#[cfg(feature = "executor-thread")]
mod thread {
use core::marker::PhantomData;
pub use hazard3_executor_macros::main_spin as main;
use crate::{Spawner, raw};
struct SpinPender;
impl crate::pender::Pender for SpinPender {
fn pend(_context: *mut ()) {}
}
pender_impl!(SpinPender);
pub struct Executor {
inner: raw::Executor,
not_send: PhantomData<*mut ()>,
}
impl Executor {
pub fn new() -> Self {
Self {
inner: raw::Executor::new(core::ptr::null_mut()),
not_send: PhantomData,
}
}
pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! {
init(self.inner.spawner());
loop {
unsafe { self.inner.poll() };
}
}
}
}