refactor next_event

This commit is contained in:
dignifiedquire
2020-05-13 18:42:56 +02:00
parent 8a7923c974
commit b25bec53d8
6 changed files with 10 additions and 38 deletions

View File

@@ -41,12 +41,8 @@ async fn main() {
let ctx1 = ctx.clone();
async_std::task::spawn(async move {
loop {
if ctx1.has_next_event() {
if let Ok(event) = ctx1.get_next_event() {
cb(event);
}
} else {
async_std::task::sleep(time::Duration::from_millis(50)).await;
if let Ok(event) = ctx1.get_next_event() {
cb(event);
}
}
});