Skip to content

Commit 433d96f

Browse files
author
Jason M. Miller
committed
feat: Add names to IO threads
This would have sped up debugging #243 had it already been implemented, and other threads are named, so I'm guessing the lack of a name is an oversight.
1 parent 0e45a86 commit 433d96f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

libshpool/src/protocol.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ impl Client {
249249
let exit_status = AtomicI32::new(1);
250250
thread::scope(|s| {
251251
// stdin -> sock
252-
let stdin_to_sock_h = s.spawn(|| -> anyhow::Result<()> {
252+
let stdin_to_sock_h = thread::Builder::new()
253+
.name("stdin_to_sock".to_string())
254+
.spawn_scoped(s,|| -> anyhow::Result<()> {
253255
let _s = span!(Level::INFO, "stdin->sock").entered();
254256
let mut stdin = std::io::stdin().lock();
255257
let mut buf = vec![0; consts::BUF_SIZE];
@@ -267,10 +269,12 @@ impl Client {
267269
write_client_stream.write_all(to_write)?;
268270
write_client_stream.flush().context("flushing client")?;
269271
}
270-
});
272+
}).unwrap();
271273

272274
// sock -> stdout
273-
let sock_to_stdout_h = s.spawn(|| -> anyhow::Result<()> {
275+
let sock_to_stdout_h = thread::Builder::new()
276+
.name("sock_to_stdout".to_string())
277+
.spawn_scoped(s, || -> anyhow::Result<()> {
274278
let _s = span!(Level::INFO, "sock->stdout").entered();
275279

276280
let mut stdout = std::io::stdout().lock();
@@ -323,7 +327,7 @@ impl Client {
323327
}
324328
}
325329
}
326-
});
330+
}).unwrap();
327331

328332
loop {
329333
let mut nfinished_threads = 0;

0 commit comments

Comments
 (0)