#[allow(unused_variables)]
fn root_notified_inner(this: &RootWakeState) -> bool {
this.notified.load(std::sync::atomic::Ordering::Acquire)
}
#[allow(unused_variables)]
fn root_wake_inner(this: &RootWakeState) {
if !this.notified.swap(true, std::sync::atomic::Ordering::Release) {
this.thread.unpark();
}
}
#[allow(unused_variables)]
fn root_park_inner(this: &RootWakeState) {
while !this.is_notified() {
std::thread::park();
}
}
#[allow(unused_variables)]
fn root_block_on_inner<F: Future>(future: F) -> F::Output {
let _scope = DriveScope::enter();
let root = Arc::new(RootWakeState {
thread: std::thread::current(),
notified: AtomicBool::new(true),
});
let waker = Waker::from(root.clone());
let mut context = Context::from_waker(&waker);
let mut future = std::pin::pin!(future);
loop {
if root.notified.swap(false, std::sync::atomic::Ordering::Acquire) {
if let Poll::Ready(output) = future.as_mut().poll(&mut context) {
return output;
}
}
root.park();
}
}
#[allow(unused_variables)]
fn driver_block_on_inner<F: Future, D: BlockOnDriver>(future: F, driver: &mut D) -> F::Output {
let _scope = DriveScope::enter();
let root = Arc::new(RootWakeState {
thread: std::thread::current(),
notified: AtomicBool::new(true),
});
let waker = Waker::from(root.clone());
let mut context = Context::from_waker(&waker);
let mut future = std::pin::pin!(future);
loop {
if root.notified.swap(false, std::sync::atomic::Ordering::Acquire) {
if let Poll::Ready(output) = future.as_mut().poll(&mut context) {
return output;
}
}
if !driver.turn() {
driver.park(&root);
}
}
}