reifydb_core/interface/catalog/
task.rs1use std::{
5 fmt,
6 sync::atomic::{AtomicU64, Ordering},
7};
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10pub struct TaskId(u64);
11
12impl TaskId {
13 pub fn new() -> Self {
14 static COUNTER: AtomicU64 = AtomicU64::new(1);
15 Self(COUNTER.fetch_add(1, Ordering::Relaxed))
16 }
17}
18
19impl Default for TaskId {
20 fn default() -> Self {
21 Self::new()
22 }
23}
24
25impl fmt::Display for TaskId {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 write!(f, "task-{}", self.0)
28 }
29}