diff options
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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") + } +} |