veecle_osal_api/
thread.rs

1//! Abstractions for thread-related operations.
2
3use core::num::NonZeroU64;
4
5/// `ThreadAbstraction` is used to query thread-related information in a platform-agnostic manner.
6pub trait ThreadAbstraction {
7    /// Returns a unique identifier for the current thread.
8    ///
9    /// The returned id is guaranteed to be unique within the lifetime of the process.
10    /// Thread ids are not reused, even after a thread terminates.
11    ///
12    /// This is useful for telemetry and tracing, where thread ids can be included
13    /// in spans and logs to help correlate events to specific threads of execution.
14    ///
15    /// # Example
16    ///
17    /// ```rust
18    /// use veecle_osal_api::thread::ThreadAbstraction;
19    /// use veecle_osal_std::thread::Thread;
20    ///
21    /// let thread_id = Thread::current_thread_id();
22    /// println!("Current thread id: {}", thread_id);
23    /// ```
24    fn current_thread_id() -> NonZeroU64;
25}