|
|
|
@ -343,18 +343,17 @@ impl Degeon {
|
|
|
|
|
impl Stream for Degeon { |
|
|
|
|
type Item = GuiEvent; |
|
|
|
|
|
|
|
|
|
fn poll_next(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { |
|
|
|
|
if self.ironforce.try_lock().is_err() { |
|
|
|
|
return Poll::Ready(Some(GuiEvent::None)); |
|
|
|
|
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { |
|
|
|
|
if self.ironforce.lock().unwrap().messages.is_empty() { |
|
|
|
|
let waker = cx.waker().clone(); |
|
|
|
|
std::thread::spawn(move || { |
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(1000)); |
|
|
|
|
waker.wake(); |
|
|
|
|
}); |
|
|
|
|
return Poll::Pending; |
|
|
|
|
} |
|
|
|
|
let timestamp_0 = std::time::Instant::now(); |
|
|
|
|
let msg = self.read_message_and_create_event(); |
|
|
|
|
if timestamp_0.elapsed() < std::time::Duration::from_millis(5) { |
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(5)); |
|
|
|
|
if rand::random::<bool>() { |
|
|
|
|
return Poll::Pending; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if timestamp_0.elapsed() > std::time::Duration::from_millis(800) { |
|
|
|
|
println!("Poll_next took {:?}", timestamp_0.elapsed()); |
|
|
|
|
} |
|
|
|
|