diff options
author | Aleksey Kladov <[email protected]> | 2018-09-08 10:36:02 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-08 10:36:02 +0100 |
commit | 326ffcefe09906560a03d3184a2ce76841448702 (patch) | |
tree | ca6c3b738122d87ed849c757087b3b5a3b7c2048 /crates/server/tests | |
parent | d9ccebd913c767779e47f0c752e9f2f3dc35c080 (diff) |
Deal with deadlocks in a more principaled way
Diffstat (limited to 'crates/server/tests')
-rw-r--r-- | crates/server/tests/heavy_tests/support.rs | 18 |
1 files changed, 11 insertions, 7 deletions
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::{ | |||
8 | }; | 8 | }; |
9 | 9 | ||
10 | use tempdir::TempDir; | 10 | use tempdir::TempDir; |
11 | use crossbeam_channel::{unbounded, after, Sender, Receiver}; | 11 | use crossbeam_channel::{after, Sender, Receiver}; |
12 | use flexi_logger::Logger; | 12 | use flexi_logger::Logger; |
13 | use languageserver_types::{ | 13 | use languageserver_types::{ |
14 | Url, | 14 | Url, |
@@ -22,7 +22,7 @@ use serde::Serialize; | |||
22 | use serde_json::{Value, from_str, to_string_pretty}; | 22 | use serde_json::{Value, from_str, to_string_pretty}; |
23 | use gen_lsp_server::{RawMessage, RawRequest, RawNotification}; | 23 | use gen_lsp_server::{RawMessage, RawRequest, RawNotification}; |
24 | 24 | ||
25 | use m::{Result, main_loop, req}; | 25 | use m::{Result, main_loop, req, thread_watcher::worker_chan}; |
26 | 26 | ||
27 | pub fn project(fixture: &str) -> Server { | 27 | pub fn project(fixture: &str) -> Server { |
28 | static INIT: Once = Once::new(); | 28 | static INIT: Once = Once::new(); |
@@ -69,15 +69,19 @@ pub struct Server { | |||
69 | impl Server { | 69 | impl Server { |
70 | fn new(dir: TempDir, files: Vec<(PathBuf, String)>) -> Server { | 70 | fn new(dir: TempDir, files: Vec<(PathBuf, String)>) -> Server { |
71 | let path = dir.path().to_path_buf(); | 71 | let path = dir.path().to_path_buf(); |
72 | let (client_sender, mut server_receiver) = unbounded(); | 72 | let ((msg_sender, msg_receiver), server) = { |
73 | let (mut server_sender, client_receiver) = unbounded(); | 73 | let (api, mut msg_receiver, mut msg_sender) = worker_chan::<RawMessage, RawMessage>(128); |
74 | let server = thread::spawn(move || main_loop(true, path, &mut server_receiver, &mut server_sender)); | 74 | let server = thread::spawn(move || { |
75 | main_loop(true, path, &mut msg_receiver, &mut msg_sender) | ||
76 | }); | ||
77 | (api, server) | ||
78 | }; | ||
75 | let res = Server { | 79 | let res = Server { |
76 | req_id: Cell::new(1), | 80 | req_id: Cell::new(1), |
77 | dir, | 81 | dir, |
78 | messages: Default::default(), | 82 | messages: Default::default(), |
79 | sender: Some(client_sender), | 83 | sender: Some(msg_sender), |
80 | receiver: client_receiver, | 84 | receiver: msg_receiver, |
81 | server: Some(server), | 85 | server: Some(server), |
82 | }; | 86 | }; |
83 | 87 | ||