#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ThreadId(usize);
impl ThreadId {
#[inline]
pub const fn new(id: usize) -> Self {
Self(id)
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ProcessId(usize);
impl ProcessId {
#[inline]
pub const fn new(id: usize) -> Self {
Self(id)
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ServerId(usize);
impl ServerId {
#[inline]
pub const fn new(id: usize) -> Self {
Self(id)
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct AsyncLaneId(usize);
impl AsyncLaneId {
#[inline]
pub const fn new(id: usize) -> Self {
Self(id)
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct AcceleratorId(usize);
impl AcceleratorId {
#[inline]
pub const fn new(id: usize) -> Self {
Self(id)
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AcceleratorKind {
Cpu,
Gpu,
Tpu,
Npu,
}
impl AcceleratorKind {
#[inline]
pub(crate) const fn checksum_tag(self) -> usize {
match self {
Self::Cpu => 1,
Self::Gpu => 2,
Self::Tpu => 3,
Self::Npu => 4,
}
}
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct WorkerCount(usize);
impl WorkerCount {
#[inline]
pub const fn new(count: usize) -> Self {
Self(if count == 0 { 1 } else { count })
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ProcessCount(usize);
impl ProcessCount {
#[inline]
pub const fn new(count: usize) -> Self {
Self(if count == 0 { 1 } else { count })
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AsyncLanesPerProcess(usize);
impl AsyncLanesPerProcess {
#[inline]
pub const fn new(count: usize) -> Self {
Self(if count == 0 { 1 } else { count })
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ServerCount(usize);
impl ServerCount {
#[inline]
pub const fn new(count: usize) -> Self {
Self(count)
}
#[inline]
pub const fn get(self) -> usize {
self.0
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct AcceleratorCounts {
cpu: usize,
gpu: usize,
tpu: usize,
npu: usize,
}
impl AcceleratorCounts {
#[inline]
pub const fn new(cpu: usize, gpu: usize, tpu: usize, npu: usize) -> Self {
Self { cpu, gpu, tpu, npu }
}
#[inline]
pub const fn cpu(self) -> usize {
self.cpu
}
#[inline]
pub const fn gpu(self) -> usize {
self.gpu
}
#[inline]
pub const fn tpu(self) -> usize {
self.tpu
}
#[inline]
pub const fn npu(self) -> usize {
self.npu
}
#[inline]
pub const fn total(self) -> usize {
self.cpu + self.gpu + self.tpu + self.npu
}
}