aboutsummaryrefslogtreecommitdiff
path: root/src/utils/id.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-08-31 10:29:06 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-09-01 23:47:19 -0700
commitb7901579d586b6c68119ef65bc184a7369492791 (patch)
tree2385b41fc227702192db5a9ef8caebdc30b32ec8 /src/utils/id.rs
parent138c2a3bfd5d12efaeffcbf92dd14f8c26dbaafc (diff)
downloadniri-b7901579d586b6c68119ef65bc184a7369492791.tar.gz
niri-b7901579d586b6c68119ef65bc184a7369492791.tar.bz2
niri-b7901579d586b6c68119ef65bc184a7369492791.zip
Change IdCounter to be backed by an AtomicU64
Let's see if anyone complains.
Diffstat (limited to 'src/utils/id.rs')
-rw-r--r--src/utils/id.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/utils/id.rs b/src/utils/id.rs
index 94d7f8ee..c21511e6 100644
--- a/src/utils/id.rs
+++ b/src/utils/id.rs
@@ -1,11 +1,8 @@
-use std::sync::atomic::{AtomicU32, Ordering};
+use std::sync::atomic::{AtomicU64, Ordering};
/// Counter that returns unique IDs.
-///
-/// Under the hood it uses a `u32` that will eventually wrap around. When incrementing it once a
-/// second, it will wrap around after about 136 years.
pub struct IdCounter {
- value: AtomicU32,
+ value: AtomicU64,
}
impl IdCounter {
@@ -13,11 +10,11 @@ impl IdCounter {
Self {
// Start from 1 to reduce the possibility that some other code that uses these IDs will
// get confused.
- value: AtomicU32::new(1),
+ value: AtomicU64::new(1),
}
}
- pub fn next(&self) -> u32 {
+ pub fn next(&self) -> u64 {
self.value.fetch_add(1, Ordering::Relaxed)
}
}