From c4b0d3cd56ab68f4fa23f7c1f6c76f7f6148153e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 21:52:49 +0300 Subject: make parent module cancelable --- crates/ra_lsp_server/src/main_loop/handlers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server/src/main_loop') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 639fe4553..b0b983d0c 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -238,7 +238,7 @@ pub fn handle_parent_module( ) -> Result> { let file_id = params.try_conv_with(&world)?; let mut res = Vec::new(); - for (file_id, symbol) in world.analysis().parent_module(file_id) { + for (file_id, symbol) in world.analysis().parent_module(file_id)? { let line_index = world.analysis().file_line_index(file_id); let location = to_location(file_id, symbol.node_range, &world, &line_index)?; res.push(location); -- cgit v1.2.3 From 998f2ae7627053a9363a05a1ab79359882dce39f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 22:02:41 +0300 Subject: remove job tokens --- crates/ra_lsp_server/src/main_loop/handlers.rs | 62 +++++++++++++------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index b0b983d0c..9e76a51c1 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -161,7 +161,7 @@ pub fn handle_document_symbol( pub fn handle_workspace_symbol( world: ServerWorld, params: req::WorkspaceSymbolParams, - token: JobToken, + _token: JobToken, ) -> Result>> { let all_symbols = params.query.contains("#"); let libs = params.query.contains("*"); @@ -181,11 +181,11 @@ pub fn handle_workspace_symbol( q.limit(128); q }; - let mut res = exec_query(&world, query, &token)?; + let mut res = exec_query(&world, query)?; if res.is_empty() && !all_symbols { let mut query = Query::new(params.query); query.limit(128); - res = exec_query(&world, query, &token)?; + res = exec_query(&world, query)?; } return Ok(Some(res)); @@ -193,10 +193,9 @@ pub fn handle_workspace_symbol( fn exec_query( world: &ServerWorld, query: Query, - token: &JobToken, ) -> Result> { let mut res = Vec::new(); - for (file_id, symbol) in world.analysis().symbol_search(query, token) { + for (file_id, symbol) in world.analysis().symbol_search(query) { let line_index = world.analysis().file_line_index(file_id); let info = SymbolInformation { name: symbol.name.to_string(), @@ -214,7 +213,7 @@ pub fn handle_workspace_symbol( pub fn handle_goto_definition( world: ServerWorld, params: req::TextDocumentPositionParams, - token: JobToken, + _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -222,7 +221,7 @@ pub fn handle_goto_definition( let mut res = Vec::new(); for (file_id, symbol) in world .analysis() - .approximately_resolve_symbol(file_id, offset, &token) + .approximately_resolve_symbol(file_id, offset) { let line_index = world.analysis().file_line_index(file_id); let location = to_location(file_id, symbol.node_range, &world, &line_index)?; @@ -255,14 +254,14 @@ pub fn handle_runnables( let line_index = world.analysis().file_line_index(file_id); let offset = params.position.map(|it| it.conv_with(&line_index)); let mut res = Vec::new(); - for runnable in world.analysis().runnables(file_id) { + for runnable in world.analysis().runnables(file_id)? { if let Some(offset) = offset { if !contains_offset_nonstrict(runnable.range, offset) { continue; } } - let args = runnable_args(&world, file_id, &runnable.kind); + let args = runnable_args(&world, file_id, &runnable.kind)?; let r = req::Runnable { range: runnable.range.conv_with(&line_index), @@ -282,9 +281,9 @@ pub fn handle_runnables( } return Ok(res); - fn runnable_args(world: &ServerWorld, file_id: FileId, kind: &RunnableKind) -> Vec { - let spec = if let Some(&crate_id) = world.analysis().crate_for(file_id).first() { - let file_id = world.analysis().crate_root(crate_id); + fn runnable_args(world: &ServerWorld, file_id: FileId, kind: &RunnableKind) -> Result> { + let spec = if let Some(&crate_id) = world.analysis().crate_for(file_id)?.first() { + let file_id = world.analysis().crate_root(crate_id)?; let path = world.path_map.get_path(file_id); world .workspaces @@ -319,7 +318,7 @@ pub fn handle_runnables( } } } - res + Ok(res) } fn spec_args(pkg_name: &str, tgt_name: &str, tgt_kind: TargetKind, buf: &mut Vec) { @@ -356,7 +355,7 @@ pub fn handle_decorations( _token: JobToken, ) -> Result> { let file_id = params.try_conv_with(&world)?; - Ok(highlight(&world, file_id)) + highlight(&world, file_id) } pub fn handle_completion( @@ -367,7 +366,7 @@ pub fn handle_completion( let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); let offset = params.position.conv_with(&line_index); - let items = match world.analysis().completions(file_id, offset) { + let items = match world.analysis().completions(file_id, offset)? { None => return Ok(None), Some(items) => items, }; @@ -427,7 +426,7 @@ pub fn handle_folding_range( pub fn handle_signature_help( world: ServerWorld, params: req::TextDocumentPositionParams, - token: JobToken, + _token: JobToken, ) -> Result> { use languageserver_types::{ParameterInformation, SignatureInformation}; @@ -436,7 +435,7 @@ pub fn handle_signature_help( let offset = params.position.conv_with(&line_index); if let Some((descriptor, active_param)) = - world.analysis().resolve_callable(file_id, offset, &token) + world.analysis().resolve_callable(file_id, offset) { let parameters: Vec = descriptor .params @@ -466,7 +465,7 @@ pub fn handle_signature_help( pub fn handle_prepare_rename( world: ServerWorld, params: req::TextDocumentPositionParams, - token: JobToken, + _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -474,7 +473,7 @@ pub fn handle_prepare_rename( // We support renaming references like handle_rename does. // In the future we may want to reject the renaming of things like keywords here too. - let refs = world.analysis().find_all_refs(file_id, offset, &token); + let refs = world.analysis().find_all_refs(file_id, offset); if refs.is_empty() { return Ok(None); } @@ -488,7 +487,7 @@ pub fn handle_prepare_rename( pub fn handle_rename( world: ServerWorld, params: RenameParams, - token: JobToken, + _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -498,7 +497,7 @@ pub fn handle_rename( return Ok(None); } - let refs = world.analysis().find_all_refs(file_id, offset, &token); + let refs = world.analysis().find_all_refs(file_id, offset); if refs.is_empty() { return Ok(None); } @@ -525,13 +524,13 @@ pub fn handle_rename( pub fn handle_references( world: ServerWorld, params: req::ReferenceParams, - token: JobToken, + _token: JobToken, ) -> Result>> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); let offset = params.position.conv_with(&line_index); - let refs = world.analysis().find_all_refs(file_id, offset, &token); + let refs = world.analysis().find_all_refs(file_id, offset); Ok(Some(refs.into_iter() .filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()) @@ -547,10 +546,10 @@ pub fn handle_code_action( let line_index = world.analysis().file_line_index(file_id); let range = params.range.conv_with(&line_index); - let assists = world.analysis().assists(file_id, range).into_iter(); + let assists = world.analysis().assists(file_id, range)?.into_iter(); let fixes = world .analysis() - .diagnostics(file_id) + .diagnostics(file_id)? .into_iter() .filter_map(|d| Some((d.range, d.fix?))) .filter(|(range, _fix)| contains_offset_nonstrict(*range, range.start())) @@ -579,7 +578,7 @@ pub fn publish_diagnostics( let line_index = world.analysis().file_line_index(file_id); let diagnostics = world .analysis() - .diagnostics(file_id) + .diagnostics(file_id)? .into_iter() .map(|d| Diagnostic { range: d.range.conv_with(&line_index), @@ -600,19 +599,20 @@ pub fn publish_decorations( let uri = world.file_id_to_uri(file_id)?; Ok(req::PublishDecorationsParams { uri, - decorations: highlight(&world, file_id), + decorations: highlight(&world, file_id)?, }) } -fn highlight(world: &ServerWorld, file_id: FileId) -> Vec { +fn highlight(world: &ServerWorld, file_id: FileId) -> Result> { let line_index = world.analysis().file_line_index(file_id); - world + let res = world .analysis() - .highlight(file_id) + .highlight(file_id)? .into_iter() .map(|h| Decoration { range: h.range.conv_with(&line_index), tag: h.tag, }) - .collect() + .collect(); + Ok(res) } -- cgit v1.2.3 From 9fb41716de095fa365eecedab3427af7b5001644 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 22:09:12 +0300 Subject: make more things cancelable --- crates/ra_lsp_server/src/main_loop/handlers.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 9e76a51c1..78a8ccfc5 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -195,7 +195,7 @@ pub fn handle_workspace_symbol( query: Query, ) -> Result> { let mut res = Vec::new(); - for (file_id, symbol) in world.analysis().symbol_search(query) { + for (file_id, symbol) in world.analysis().symbol_search(query)? { let line_index = world.analysis().file_line_index(file_id); let info = SymbolInformation { name: symbol.name.to_string(), @@ -221,7 +221,7 @@ pub fn handle_goto_definition( let mut res = Vec::new(); for (file_id, symbol) in world .analysis() - .approximately_resolve_symbol(file_id, offset) + .approximately_resolve_symbol(file_id, offset)? { let line_index = world.analysis().file_line_index(file_id); let location = to_location(file_id, symbol.node_range, &world, &line_index)?; @@ -435,7 +435,7 @@ pub fn handle_signature_help( let offset = params.position.conv_with(&line_index); if let Some((descriptor, active_param)) = - world.analysis().resolve_callable(file_id, offset) + world.analysis().resolve_callable(file_id, offset)? { let parameters: Vec = descriptor .params @@ -473,7 +473,7 @@ pub fn handle_prepare_rename( // We support renaming references like handle_rename does. // In the future we may want to reject the renaming of things like keywords here too. - let refs = world.analysis().find_all_refs(file_id, offset); + let refs = world.analysis().find_all_refs(file_id, offset)?; if refs.is_empty() { return Ok(None); } @@ -497,7 +497,7 @@ pub fn handle_rename( return Ok(None); } - let refs = world.analysis().find_all_refs(file_id, offset); + let refs = world.analysis().find_all_refs(file_id, offset)?; if refs.is_empty() { return Ok(None); } @@ -530,7 +530,7 @@ pub fn handle_references( let line_index = world.analysis().file_line_index(file_id); let offset = params.position.conv_with(&line_index); - let refs = world.analysis().find_all_refs(file_id, offset); + let refs = world.analysis().find_all_refs(file_id, offset)?; Ok(Some(refs.into_iter() .filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()) -- cgit v1.2.3 From 6e88aaef5d49c8ec7b6ffe6b41457c3a028b4eb0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 22:38:47 +0300 Subject: use pythonic import order use std // blank line use extern crates // blank line use crate::{} --- crates/ra_lsp_server/src/main_loop/handlers.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 78a8ccfc5..673f1bf7d 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -1,5 +1,6 @@ -use rustc_hash::FxHashMap; +use std::collections::HashMap; +use rustc_hash::FxHashMap; use languageserver_types::{ CodeActionResponse, Command, CompletionItem, CompletionItemKind, Diagnostic, DiagnosticSeverity, DocumentSymbol, FoldingRange, FoldingRangeKind, FoldingRangeParams, @@ -18,8 +19,6 @@ use crate::{ Result, }; -use std::collections::HashMap; - pub fn handle_syntax_tree( world: ServerWorld, params: req::SyntaxTreeParams, -- cgit v1.2.3 From 0102a01f76c855da447e25eb81191047a3ca79b8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 20 Oct 2018 22:59:54 +0300 Subject: Remove job handle --- crates/ra_lsp_server/src/main_loop/handlers.rs | 21 +------------- crates/ra_lsp_server/src/main_loop/mod.rs | 38 ++++++++++++-------------- 2 files changed, 18 insertions(+), 41 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 673f1bf7d..f5dff4c80 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -7,7 +7,7 @@ use languageserver_types::{ InsertTextFormat, Location, Position, SymbolInformation, TextDocumentIdentifier, TextEdit, RenameParams, WorkspaceEdit, PrepareRenameResponse }; -use ra_analysis::{FileId, FoldKind, JobToken, Query, RunnableKind}; +use ra_analysis::{FileId, FoldKind, Query, RunnableKind}; use ra_syntax::text_utils::contains_offset_nonstrict; use serde_json::to_value; @@ -22,7 +22,6 @@ use crate::{ pub fn handle_syntax_tree( world: ServerWorld, params: req::SyntaxTreeParams, - _token: JobToken, ) -> Result { let id = params.text_document.try_conv_with(&world)?; let res = world.analysis().syntax_tree(id); @@ -32,7 +31,6 @@ pub fn handle_syntax_tree( pub fn handle_extend_selection( world: ServerWorld, params: req::ExtendSelectionParams, - _token: JobToken, ) -> Result { let file_id = params.text_document.try_conv_with(&world)?; let file = world.analysis().file_syntax(file_id); @@ -50,7 +48,6 @@ pub fn handle_extend_selection( pub fn handle_find_matching_brace( world: ServerWorld, params: req::FindMatchingBraceParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let file = world.analysis().file_syntax(file_id); @@ -73,7 +70,6 @@ pub fn handle_find_matching_brace( pub fn handle_join_lines( world: ServerWorld, params: req::JoinLinesParams, - _token: JobToken, ) -> Result { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -87,7 +83,6 @@ pub fn handle_join_lines( pub fn handle_on_enter( world: ServerWorld, params: req::TextDocumentPositionParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -101,7 +96,6 @@ pub fn handle_on_enter( pub fn handle_on_type_formatting( world: ServerWorld, params: req::DocumentOnTypeFormattingParams, - _token: JobToken, ) -> Result>> { if params.ch != "=" { return Ok(None); @@ -121,7 +115,6 @@ pub fn handle_on_type_formatting( pub fn handle_document_symbol( world: ServerWorld, params: req::DocumentSymbolParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -160,7 +153,6 @@ pub fn handle_document_symbol( pub fn handle_workspace_symbol( world: ServerWorld, params: req::WorkspaceSymbolParams, - _token: JobToken, ) -> Result>> { let all_symbols = params.query.contains("#"); let libs = params.query.contains("*"); @@ -212,7 +204,6 @@ pub fn handle_workspace_symbol( pub fn handle_goto_definition( world: ServerWorld, params: req::TextDocumentPositionParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -232,7 +223,6 @@ pub fn handle_goto_definition( pub fn handle_parent_module( world: ServerWorld, params: TextDocumentIdentifier, - _token: JobToken, ) -> Result> { let file_id = params.try_conv_with(&world)?; let mut res = Vec::new(); @@ -247,7 +237,6 @@ pub fn handle_parent_module( pub fn handle_runnables( world: ServerWorld, params: req::RunnablesParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -351,7 +340,6 @@ pub fn handle_runnables( pub fn handle_decorations( world: ServerWorld, params: TextDocumentIdentifier, - _token: JobToken, ) -> Result> { let file_id = params.try_conv_with(&world)?; highlight(&world, file_id) @@ -360,7 +348,6 @@ pub fn handle_decorations( pub fn handle_completion( world: ServerWorld, params: req::CompletionParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -392,7 +379,6 @@ pub fn handle_completion( pub fn handle_folding_range( world: ServerWorld, params: FoldingRangeParams, - _token: JobToken, ) -> Result>> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -425,7 +411,6 @@ pub fn handle_folding_range( pub fn handle_signature_help( world: ServerWorld, params: req::TextDocumentPositionParams, - _token: JobToken, ) -> Result> { use languageserver_types::{ParameterInformation, SignatureInformation}; @@ -464,7 +449,6 @@ pub fn handle_signature_help( pub fn handle_prepare_rename( world: ServerWorld, params: req::TextDocumentPositionParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -486,7 +470,6 @@ pub fn handle_prepare_rename( pub fn handle_rename( world: ServerWorld, params: RenameParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -523,7 +506,6 @@ pub fn handle_rename( pub fn handle_references( world: ServerWorld, params: req::ReferenceParams, - _token: JobToken, ) -> Result>> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); @@ -539,7 +521,6 @@ pub fn handle_references( pub fn handle_code_action( world: ServerWorld, params: req::CodeActionParams, - _token: JobToken, ) -> Result> { let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id); diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs index 165f2e78f..b35ebd38b 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs @@ -8,9 +8,9 @@ use gen_lsp_server::{ handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse, }; use languageserver_types::NumberOrString; -use ra_analysis::{FileId, JobHandle, JobToken, LibraryData}; +use ra_analysis::{FileId, LibraryData}; use rayon::{self, ThreadPool}; -use rustc_hash::FxHashMap; +use rustc_hash::FxHashSet; use serde::{de::DeserializeOwned, Serialize}; use crate::{ @@ -47,7 +47,7 @@ pub fn main_loop( info!("server initialized, serving requests"); let mut state = ServerWorldState::new(); - let mut pending_requests = FxHashMap::default(); + let mut pending_requests = FxHashSet::default(); let mut subs = Subscriptions::new(); let main_res = main_loop_inner( internal_mode, @@ -92,7 +92,7 @@ fn main_loop_inner( fs_worker: Worker)>, ws_worker: Worker>, state: &mut ServerWorldState, - pending_requests: &mut FxHashMap, + pending_requests: &mut FxHashSet, subs: &mut Subscriptions, ) -> Result<()> { let (libdata_sender, libdata_receiver) = unbounded(); @@ -204,14 +204,13 @@ fn main_loop_inner( fn on_task( task: Task, msg_sender: &Sender, - pending_requests: &mut FxHashMap, + pending_requests: &mut FxHashSet, ) { match task { Task::Respond(response) => { - if let Some(handle) = pending_requests.remove(&response.id) { - assert!(handle.has_completed()); + if pending_requests.remove(&response.id) { + msg_sender.send(RawMessage::Response(response)) } - msg_sender.send(RawMessage::Response(response)) } Task::Notify(n) => msg_sender.send(RawMessage::Notification(n)), } @@ -219,7 +218,7 @@ fn on_task( fn on_request( world: &mut ServerWorldState, - pending_requests: &mut FxHashMap, + pending_requests: &mut FxHashSet, pool: &ThreadPool, sender: &Sender, req: RawRequest, @@ -253,8 +252,8 @@ fn on_request( .on::(handlers::handle_references)? .finish(); match req { - Ok((id, handle)) => { - let inserted = pending_requests.insert(id, handle).is_none(); + Ok(id) => { + let inserted = pending_requests.insert(id); assert!(inserted, "duplicate request: {}", id); Ok(None) } @@ -265,7 +264,7 @@ fn on_request( fn on_notification( msg_sender: &Sender, state: &mut ServerWorldState, - pending_requests: &mut FxHashMap, + pending_requests: &mut FxHashSet, subs: &mut Subscriptions, not: RawNotification, ) -> Result<()> { @@ -277,9 +276,7 @@ fn on_notification( panic!("string id's not supported: {:?}", id); } }; - if let Some(handle) = pending_requests.remove(&id) { - handle.cancel(); - } + pending_requests.remove(&id); return Ok(()); } Err(not) => not, @@ -336,7 +333,7 @@ fn on_notification( struct PoolDispatcher<'a> { req: Option, - res: Option<(u64, JobHandle)>, + res: Option, pool: &'a ThreadPool, world: &'a ServerWorldState, sender: &'a Sender, @@ -345,7 +342,7 @@ struct PoolDispatcher<'a> { impl<'a> PoolDispatcher<'a> { fn on<'b, R>( &'b mut self, - f: fn(ServerWorld, R::Params, JobToken) -> Result, + f: fn(ServerWorld, R::Params) -> Result, ) -> Result<&'b mut Self> where R: req::Request, @@ -358,11 +355,10 @@ impl<'a> PoolDispatcher<'a> { }; match req.cast::() { Ok((id, params)) => { - let (handle, token) = JobHandle::new(); let world = self.world.snapshot(); let sender = self.sender.clone(); self.pool.spawn(move || { - let resp = match f(world, params, token) { + let resp = match f(world, params) { Ok(resp) => RawResponse::ok::(id, &resp), Err(e) => { RawResponse::err(id, ErrorCode::InternalError as i32, e.to_string()) @@ -371,14 +367,14 @@ impl<'a> PoolDispatcher<'a> { let task = Task::Respond(resp); sender.send(task); }); - self.res = Some((id, handle)); + self.res = Some(id); } Err(req) => self.req = Some(req), } Ok(self) } - fn finish(&mut self) -> ::std::result::Result<(u64, JobHandle), RawRequest> { + fn finish(&mut self) -> ::std::result::Result { match (self.res.take(), self.req.take()) { (Some(res), None) => Ok(res), (None, Some(req)) => Err(req), -- cgit v1.2.3