From 326ffcefe09906560a03d3184a2ce76841448702 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 8 Sep 2018 12:36:02 +0300 Subject: Deal with deadlocks in a more principaled way --- crates/server/tests/heavy_tests/support.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'crates/server/tests/heavy_tests') diff --git a/crates/server/tests/heavy_tests/support.rs b/crates/server/tests/heavy_tests/support.rs index 297dcd9ae..2710ab59b 100644 --- a/crates/server/tests/heavy_tests/support.rs +++ b/crates/server/tests/heavy_tests/support.rs @@ -8,7 +8,7 @@ use std::{ }; use tempdir::TempDir; -use crossbeam_channel::{unbounded, after, Sender, Receiver}; +use crossbeam_channel::{after, Sender, Receiver}; use flexi_logger::Logger; use languageserver_types::{ Url, @@ -22,7 +22,7 @@ use serde::Serialize; use serde_json::{Value, from_str, to_string_pretty}; use gen_lsp_server::{RawMessage, RawRequest, RawNotification}; -use m::{Result, main_loop, req}; +use m::{Result, main_loop, req, thread_watcher::worker_chan}; pub fn project(fixture: &str) -> Server { static INIT: Once = Once::new(); @@ -69,15 +69,19 @@ pub struct Server { impl Server { fn new(dir: TempDir, files: Vec<(PathBuf, String)>) -> Server { let path = dir.path().to_path_buf(); - let (client_sender, mut server_receiver) = unbounded(); - let (mut server_sender, client_receiver) = unbounded(); - let server = thread::spawn(move || main_loop(true, path, &mut server_receiver, &mut server_sender)); + let ((msg_sender, msg_receiver), server) = { + let (api, mut msg_receiver, mut msg_sender) = worker_chan::(128); + let server = thread::spawn(move || { + main_loop(true, path, &mut msg_receiver, &mut msg_sender) + }); + (api, server) + }; let res = Server { req_id: Cell::new(1), dir, messages: Default::default(), - sender: Some(client_sender), - receiver: client_receiver, + sender: Some(msg_sender), + receiver: msg_receiver, server: Some(server), }; -- cgit v1.2.3