wgpu/backend/wgpu_core/
thread_id.rs

1//! Implementation of thread IDs for error scope tracking.
2//!
3//! Supports both std and no_std environments, though
4//! the no_std implementation is a stub that does not
5//! actually distinguish between threads.
6
7#[cfg(feature = "std")]
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub struct ThreadId(std::thread::ThreadId);
10
11#[cfg(feature = "std")]
12impl ThreadId {
13    pub fn current() -> Self {
14        ThreadId(std::thread::current().id())
15    }
16}
17
18#[cfg(not(feature = "std"))]
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
20pub struct ThreadId(());
21
22#[cfg(not(feature = "std"))]
23impl ThreadId {
24    pub fn current() -> Self {
25        // A simple stub implementation for non-std environments. On
26        // no_std but multithreaded platforms, this will work, but
27        // make error scope global rather than thread-local.
28        ThreadId(())
29    }
30}