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