use corona::prelude::*;
use tokio::prelude::*;
use tokio::runtime::current_thread;
#[derive(Debug, Default)]
struct ReentrantPoll {
reentered: bool,
}
impl Future for ReentrantPoll {
type Item = ();
type Error = ();
fn poll(&mut self) -> Poll<(), ()> {
if self.reentered {
return Ok(Async::Ready(()));
}
self.reentered = true;
match self.coro_wait() {
Ok(()) => Ok(Async::Ready(())),
Err(()) => Err(()),
}
}
}
#[test]
fn directly_reentrant() {
current_thread::block_on_all(future::lazy(|| {
Coroutine::new()
.spawn_catch_panic(|| {
ReentrantPoll::default().coro_wait()
}).unwrap()
})).unwrap_err(); }