use std::time::{Duration, Instant};
use teksilo_async::AsyncRuntimeHandle;
use teksilo_core::Signal;
#[test]
fn executor_awaits_an_async_std_timer() {
let rt = AsyncRuntimeHandle::new();
let done = Signal::new(false);
let sink = done.clone();
rt.spawn_local(async move {
async_std::task::sleep(Duration::from_millis(50)).await;
sink.set(true);
})
.detach();
let start = Instant::now();
while !done.get() {
rt.tick(); if start.elapsed() > Duration::from_secs(5) {
panic!("async_std::task::sleep never resolved on the main-thread executor");
}
std::thread::sleep(Duration::from_millis(2));
}
assert!(done.get());
}