MCPcopy Index your code
hub / github.com/RustPython/RustPython / thread_to_rust_id

Function thread_to_rust_id

crates/vm/src/stdlib/_thread.rs:443–462  ·  view source on GitHub ↗
(t: &thread::Thread)

Source from the content-addressed store, hash-verified

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 {

Callers 2

current_thread_idFunction · 0.85
thread_to_idFunction · 0.85

Calls 3

hashMethod · 0.45
idMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected