diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 93cf6a3d68b..e55f74bc452 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -67,7 +67,10 @@ pub fn spawn( ) -> FlycheckHandle { let actor = FlycheckActor::new(id, sender, config, workspace_root); let (sender, receiver) = unbounded::(); - let thread = jod_thread::spawn(move || actor.run(receiver)); + let thread = jod_thread::Builder::new() + .name("FlycheckThread".to_owned()) + .spawn(move || actor.run(receiver)) + .expect("failed to spawn thread"); FlycheckHandle { sender, thread } } @@ -266,7 +269,10 @@ fn spawn(mut child: JodChild) -> CargoHandle { let child_stdout = child.stdout.take().unwrap(); let (sender, receiver) = unbounded(); let actor = CargoActor::new(child_stdout, sender); - let thread = jod_thread::spawn(move || actor.run()); + let thread = jod_thread::Builder::new() + .name("CargoHandleThread".to_owned()) + .spawn(move || actor.run()) + .expect("failed to spawn thread"); CargoHandle { child, thread, receiver } } fn join(mut self) -> io::Result<()> { diff --git a/crates/proc_macro_api/src/process.rs b/crates/proc_macro_api/src/process.rs index 38eac6c17fa..19f854dba12 100644 --- a/crates/proc_macro_api/src/process.rs +++ b/crates/proc_macro_api/src/process.rs @@ -37,9 +37,12 @@ pub(crate) fn run( let process = Process::run(process_path, args)?; let (task_tx, task_rx) = bounded(0); - let handle = jod_thread::spawn(move || { - client_loop(task_rx, process); - }); + let handle = jod_thread::Builder::new() + .name("ProcMacroClientThread".to_owned()) + .spawn(move || { + client_loop(task_rx, process); + }) + .expect("failed to spawn thread"); let task_tx = Arc::new(task_tx); let srv = ProcMacroProcessSrv { inner: Arc::downgrade(&task_tx) }; diff --git a/crates/proc_macro_srv/src/proc_macro/bridge/server.rs b/crates/proc_macro_srv/src/proc_macro/bridge/server.rs index cc9afd84b1c..29b340445ef 100644 --- a/crates/proc_macro_srv/src/proc_macro/bridge/server.rs +++ b/crates/proc_macro_srv/src/proc_macro/bridge/server.rs @@ -181,21 +181,24 @@ fn run_bridge_and_client( let (req_tx, req_rx) = channel(); let (res_tx, res_rx) = channel(); - let join_handle = thread::spawn(move || { - let mut dispatch = |b| { - req_tx.send(b).unwrap(); - res_rx.recv().unwrap() - }; + let join_handle = thread::Builder::new() + .name("DispatchThread".to_owned()) + .spawn(move || { + let mut dispatch = |b| { + req_tx.send(b).unwrap(); + res_rx.recv().unwrap() + }; - run_client( - Bridge { - cached_buffer: input, - dispatch: (&mut dispatch).into(), - force_show_panics, - }, - client_data, - ) - }); + run_client( + Bridge { + cached_buffer: input, + dispatch: (&mut dispatch).into(), + force_show_panics, + }, + client_data, + ) + }) + .expect("failed to spawn thread"); for b in req_rx { res_tx.send(dispatcher.dispatch(b)).unwrap(); @@ -227,33 +230,36 @@ enum State { let server_thread = thread::current(); let state2 = state.clone(); - let join_handle = thread::spawn(move || { - let mut dispatch = |b| { - *state2.lock().unwrap() = State::Req(b); - server_thread.unpark(); - loop { - thread::park(); - if let State::Res(b) = &mut *state2.lock().unwrap() { - break b.take(); + let join_handle = thread::Builder::new() + .name("ServerThread".to_owned()) + .spawn(move || { + let mut dispatch = |b| { + *state2.lock().unwrap() = State::Req(b); + server_thread.unpark(); + loop { + thread::park(); + if let State::Res(b) = &mut *state2.lock().unwrap() { + break b.take(); + } } - } - }; + }; - let r = run_client( - Bridge { - cached_buffer: input, - dispatch: (&mut dispatch).into(), - force_show_panics, - }, - client_data, - ); + let r = run_client( + Bridge { + cached_buffer: input, + dispatch: (&mut dispatch).into(), + force_show_panics, + }, + client_data, + ); - // Wake up the server so it can exit the dispatch loop. - drop(state2); - server_thread.unpark(); + // Wake up the server so it can exit the dispatch loop. + drop(state2); + server_thread.unpark(); - r - }); + r + }) + .expect("failed to spawn thread"); // Check whether `state2` was dropped, to know when to stop. while Arc::get_mut(&mut state).is_none() { diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index f7ae0577d2e..ca341ddae92 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -31,7 +31,10 @@ impl loader::Handle for NotifyHandle { fn spawn(sender: loader::Sender) -> NotifyHandle { let actor = NotifyActor::new(sender); let (sender, receiver) = unbounded::(); - let thread = jod_thread::spawn(move || actor.run(receiver)); + let thread = jod_thread::Builder::new() + .name("LoaderThread".to_owned()) + .spawn(move || actor.run(receiver)) + .expect("failed to spawn thread"); NotifyHandle { sender, thread } } fn set_config(&mut self, config: loader::Config) {