diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 4 | ||||
-rw-r--r-- | src/util.rs | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 2fc11f60..faf397c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ mod meter; mod tty; mod ansi; mod term; +mod util; use std::sync::mpsc::TryRecvError; use std::collections::HashMap; @@ -42,6 +43,7 @@ use text::FontDesc; use grid::Grid; use term::Term; use meter::Meter; +use util::thread; #[derive(Debug, Eq, PartialEq, Copy, Clone, Default)] pub struct Rgb { @@ -128,7 +130,7 @@ fn main() { } let (chars_tx, chars_rx) = ::std::sync::mpsc::channel(); - ::std::thread::spawn(move || { + thread::spawn_named("TTY Reader", move || { for c in reader.chars() { let c = c.unwrap(); chars_tx.send(c).unwrap(); diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 00000000..0a3de227 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,12 @@ +/// Threading utilities +pub mod thread { + /// Like `thread::spawn`, but with a `name` argument + pub fn spawn_named<F, T, S>(name: S, f: F) -> ::std::thread::JoinHandle<T> + where F: FnOnce() -> T, + F: Send + 'static, + T: Send + 'static, + S: Into<String> + { + ::std::thread::Builder::new().name(name.into()).spawn(f).expect("thread spawn works") + } +} |