1use std::{iter, mem};
2
3use crate::{Errno, kernel::errno};
4
5pub mod signal;
6pub mod timer;
7
8pub mod affinity;
9mod attrs;
10mod handle;
11pub mod raw;
12
13pub use attrs::Attrs;
14pub use handle::Handle;
15
16pub const STACK_MIN: usize = libc::PTHREAD_STACK_MIN;
18
19pub trait Thread: errno::Source {
21 type Cpus: DoubleEndedIterator<Item = affinity::raw::Cpu>
22 + ExactSizeIterator
23 + iter::FusedIterator;
24 type Timer: crate::Timer;
25 type Receiver: signal::raw::Receiver;
26
27 fn current() -> Result<Self::Cpus, affinity::Error>;
28 fn bind(cpu: affinity::raw::Cpu) -> Result<(), affinity::Error>;
29
30 fn is_main() -> bool;
32
33 fn try_crc32() -> Result<bool, Errno> {
36 raw::try_crc32(Self::read)
37 }
38
39 fn entropy<const N: usize>(
41 bytes: &mut mem::MaybeUninit<[u8; N]>,
42 ) -> Result<&mut [u8; N], Errno> {
43 raw::entropy::<Self, N>(bytes)
44 }
45}