14 lines
346 B
Rust
14 lines
346 B
Rust
|
use std::thread;
|
||
|
|
||
|
pub trait Waitable: Sized {
|
||
|
fn get_joinhandle(self) -> Option<thread::JoinHandle<()>>;
|
||
|
|
||
|
fn wait(self) {
|
||
|
if let Some(handle) = self.get_joinhandle() {
|
||
|
handle.join().expect("Couldn't join on thread!");
|
||
|
} else {
|
||
|
log::warn!("Tried to wait on non-existent thread!");
|
||
|
}
|
||
|
}
|
||
|
}
|