aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/thread.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty_terminal/src/thread.rs')
-rw-r--r--alacritty_terminal/src/thread.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/alacritty_terminal/src/thread.rs b/alacritty_terminal/src/thread.rs
new file mode 100644
index 00000000..6a93b78d
--- /dev/null
+++ b/alacritty_terminal/src/thread.rs
@@ -0,0 +1,11 @@
+use std::thread::{Builder, JoinHandle};
+
+/// Like `thread::spawn`, but with a `name` argument.
+pub fn spawn_named<F, T, S>(name: S, f: F) -> JoinHandle<T>
+where
+ F: FnOnce() -> T + Send + 'static,
+ T: Send + 'static,
+ S: Into<String>,
+{
+ Builder::new().name(name.into()).spawn(f).expect("thread spawn works")
+}