2024-05-27
最后编辑于:2024-09-15
静态初始化异步Executor
static EXECUTOR: Once<Arsc<Executor>> = Once::new();
pub fn executor() -> &'static Arsc<Executor> {
EXECUTOR.get().unwrap()
}
Once
: Lazy one-time initialization
由[[Boot]]进入
fn run_art(payload: usize);
impl<F: Future> Future for TaskFut<F> {
type Output = F::Output;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let old = unsafe { self.virt.clone().load() };
if let Some(old) = old {
if Arsc::count(&old) == 1 {
crate::executor()
.spawn(async move { old.clear().await })
.detach();
}
}
self.project().fut.poll(cx)
}
}
先切换[[地址空间]]