(t: &thread::Thread)
| 441 | /// Convert Rust thread to ID (used for non-unix platforms) |
| 442 | #[cfg(not(unix))] |
| 443 | fn thread_to_rust_id(t: &thread::Thread) -> u64 { |
| 444 | use core::hash::{Hash, Hasher}; |
| 445 | struct U64Hash { |
| 446 | v: Option<u64>, |
| 447 | } |
| 448 | impl Hasher for U64Hash { |
| 449 | fn write(&mut self, _: &[u8]) { |
| 450 | unreachable!() |
| 451 | } |
| 452 | fn write_u64(&mut self, i: u64) { |
| 453 | self.v = Some(i); |
| 454 | } |
| 455 | fn finish(&self) -> u64 { |
| 456 | self.v.expect("should have written a u64") |
| 457 | } |
| 458 | } |
| 459 | let mut h = U64Hash { v: None }; |
| 460 | t.id().hash(&mut h); |
| 461 | h.finish() |
| 462 | } |
| 463 | |
| 464 | /// Get thread ID for a given thread handle (used by start_new_thread) |
| 465 | fn thread_to_id(handle: &thread::JoinHandle<()>) -> u64 { |
no test coverage detected