use blocking recv in IO thread
authoralfadur
Sun, 02 Jun 2019 22:25:41 +0300
changeset 15098 9397e07b3086
parent 15097 260e96addf92
child 15099 07de9e60c305
use blocking recv in IO thread
rust/hedgewars-server/src/server/io.rs
rust/hedgewars-server/src/server/network.rs
--- a/rust/hedgewars-server/src/server/io.rs	Sun Jun 02 18:22:06 2019 +0200
+++ b/rust/hedgewars-server/src/server/io.rs	Sun Jun 02 22:25:41 2019 +0300
@@ -15,12 +15,12 @@
 
 pub type RequestId = u32;
 
-pub struct IOThread {
+pub struct IoThread {
     core_tx: mpsc::Sender<(RequestId, IoTask)>,
     core_rx: channel::Receiver<(RequestId, IoResult)>,
 }
 
-impl IOThread {
+impl IoThread {
     pub fn new() -> Self {
         let (core_tx, io_rx) = mpsc::channel();
         let (io_tx, core_rx) = channel::channel();
@@ -29,7 +29,7 @@
         db.connect("localhost");
 
         thread::spawn(move || {
-            while let Ok((request_id, task)) = io_rx.try_recv() {
+            while let Ok((request_id, task)) = io_rx.recv() {
                 let response = match task {
                     IoTask::GetAccount {
                         nick,
--- a/rust/hedgewars-server/src/server/network.rs	Sun Jun 02 18:22:06 2019 +0200
+++ b/rust/hedgewars-server/src/server/network.rs	Sun Jun 02 22:25:41 2019 +0300
@@ -25,7 +25,7 @@
 };
 
 #[cfg(feature = "official-server")]
-use super::io::{IOThread, RequestId};
+use super::io::{IoThread, RequestId};
 
 use crate::{
     handlers::{IoResult, IoTask},
@@ -251,7 +251,7 @@
 pub struct IoLayer {
     next_request_id: RequestId,
     request_queue: Vec<(RequestId, ClientId)>,
-    io_thread: IOThread,
+    io_thread: IoThread,
 }
 
 #[cfg(feature = "official-server")]
@@ -260,7 +260,7 @@
         Self {
             next_request_id: 0,
             request_queue: vec![],
-            io_thread: IOThread::new(),
+            io_thread: IoThread::new(),
         }
     }