1use std::sync::atomic::{AtomicU64, Ordering};
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4pub struct WidgetId(u64);
5
6impl WidgetId {
7 pub fn new() -> Self {
8 static NEXT_ID: AtomicU64 = AtomicU64::new(1);
9 Self(NEXT_ID.fetch_add(1, Ordering::Relaxed))
10 }
11
12 pub const fn from_raw(raw: u64) -> Self {
13 Self(raw)
14 }
15
16 pub const fn into_raw(self) -> u64 {
17 self.0
18 }
19}
20
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
22pub struct InstanceId(u64);
23
24impl InstanceId {
25 pub fn new() -> Self {
26 static NEXT_ID: AtomicU64 = AtomicU64::new(1);
27 Self(NEXT_ID.fetch_add(1, Ordering::Relaxed))
28 }
29
30 pub const fn from_raw(raw: u64) -> Self {
31 Self(raw)
32 }
33
34 pub const fn into_raw(self) -> u64 {
35 self.0
36 }
37}
38
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
40pub struct TimerId(u64);
41
42impl TimerId {
43 pub fn new() -> Self {
44 static NEXT_ID: AtomicU64 = AtomicU64::new(1);
45 Self(NEXT_ID.fetch_add(1, Ordering::Relaxed))
46 }
47
48 pub const fn into_raw(self) -> u64 {
49 self.0
50 }
51}
52
53#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
54pub struct TaskId(u64);
55
56impl TaskId {
57 pub fn new() -> Self {
58 static NEXT_ID: AtomicU64 = AtomicU64::new(1);
59 Self(NEXT_ID.fetch_add(1, Ordering::Relaxed))
60 }
61
62 pub const fn into_raw(self) -> u64 {
63 self.0
64 }
65}