dope_sys/thread/
handle.rs1use std::{mem::ManuallyDrop, ptr};
2
3use o3::base::marker::ThreadBound;
4
5use crate::kernel;
6
7#[repr(transparent)]
9pub struct Handle(pub(super) libc::pthread_t, pub(super) ThreadBound);
10
11impl Handle {
12 pub fn join(self) {
15 ManuallyDrop::new(self).wait();
16 }
17
18 fn wait(&self) {
19 if let Err(cause) = unsafe {
23 kernel::raw::Status::new(libc::pthread_join(self.0, ptr::null_mut())).try_pthread()
24 } {
25 kernel::Fatal::Join(cause).terminate()
26 }
27 }
28}
29
30impl Drop for Handle {
31 fn drop(&mut self) {
32 self.wait();
33 }
34}