mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 21:57:49 +02:00
Name threads (#7879)
I noticed that [it's pretty easy to name threads in Rust](https://doc.rust-lang.org/std/thread/#naming-threads). We might as well do this; it's a nice quality of life improvement when you're profiling something and the developers took the time to give threads names. Also added/cleaned up some comments while I was in the area.
This commit is contained in:
@ -5,6 +5,7 @@ use crate::{
|
||||
};
|
||||
use nu_utils::{stderr_write_all_and_flush, stdout_write_all_and_flush};
|
||||
use std::sync::{atomic::AtomicBool, Arc};
|
||||
use std::thread;
|
||||
|
||||
const LINE_ENDING_PATTERN: &[char] = &['\r', '\n'];
|
||||
|
||||
@ -726,8 +727,11 @@ pub fn print_if_stream(
|
||||
exit_code: Option<ListStream>,
|
||||
) -> Result<i64, ShellError> {
|
||||
// NOTE: currently we don't need anything from stderr
|
||||
// so directly consumes `stderr_stream` to make sure that everything is done.
|
||||
std::thread::spawn(move || stderr_stream.map(|x| x.into_bytes()));
|
||||
// so we just consume and throw away `stderr_stream` to make sure the pipe doesn't fill up
|
||||
thread::Builder::new()
|
||||
.name("stderr consumer".to_string())
|
||||
.spawn(move || stderr_stream.map(|x| x.into_bytes()))
|
||||
.expect("could not create thread");
|
||||
if let Some(stream) = stream {
|
||||
for s in stream {
|
||||
let s_live = s?;
|
||||
|
Reference in New Issue
Block a user