kernel_api/threading/mod.rs
1//! Provides an interface to the scheduler and threading subsystem
2
3mod meta;
4mod state;
5
6use core::borrow::Borrow;
7pub use meta::*;
8pub use state::*;
9
10/// The numerical ID of a thread
11///
12/// This is the same as the internal handle number by the `proc` server for
13/// this thread.
14///
15/// **This is only unique for non-kernel threads while they are alive**.
16/// All kernel threads have an invalid `ThreadId`, and `ThreadId`s will be reused
17/// after a thread is killed.
18#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
19pub struct ThreadId {
20 id: isize,
21}
22
23impl ThreadId {
24 pub const fn new(id: isize) -> Self { Self { id } }
25
26 pub const fn get(self) -> isize { self.id }
27}
28
29impl Borrow<ThreadId> for ThreadMeta {
30 fn borrow(&self) -> &ThreadId {
31 &self.thread_id
32 }
33}