# HG changeset patch # User alfadur # Date 1559503541 -10800 # Node ID 9397e07b308684ab65af3da15451045b3726e2df # Parent 260e96addf92bfdc71575ed4d93a5c6d2089d039 use blocking recv in IO thread diff -r 260e96addf92 -r 9397e07b3086 rust/hedgewars-server/src/server/io.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, diff -r 260e96addf92 -r 9397e07b3086 rust/hedgewars-server/src/server/network.rs --- 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(), } }