gameServer2/src/main.rs
changeset 13419 28b314ad566d
parent 13124 1e39b8749072
child 13426 d1368c776a4f
--- a/gameServer2/src/main.rs	Sun Jun 10 19:01:50 2018 +0200
+++ b/gameServer2/src/main.rs	Thu Jun 14 12:31:15 2018 -0400
@@ -22,6 +22,7 @@
 mod protocol;
 
 use server::network::NetworkLayer;
+use std::time::Duration;
 
 fn main() {
     env_logger::init().unwrap();
@@ -38,7 +39,12 @@
     let mut events = Events::with_capacity(1024);
 
     loop {
-        poll.poll(&mut events, None).unwrap();
+        let timeout = if hw_network.has_pending_operations() {
+            Some(Duration::from_millis(1))
+        } else {
+            None
+        };
+        poll.poll(&mut events, timeout).unwrap();
 
         for event in events.iter() {
             if event.readiness() & Ready::readable() == Ready::readable() {
@@ -60,5 +66,6 @@
 //                }
 //            }
         }
+        hw_network.on_idle(&poll).unwrap();
     }
 }