1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! # Task identity
//!
//! [`TaskId`] is the opaque identity reserved for one task submission.
//!
//! Direct `add*` methods return it after the registry accepts a task.
//! Controller `submit*` methods return it after queueing, before slot admission.
//! The same ID therefore also identifies a controller submission that is rejected without running.
//!
//! ## TaskId vs Name vs Slot
//!
//! | Concept | Owned by | Meaning |
//! |------------------|------------|-------------------------------------------------------------|
//! | [`TaskId`] | Taskvisor | identity of one submission and its run, if admitted |
//! | task name | task | human label used for logs, metrics, and registry uniqueness |
//! | controller slot | controller | admission key for "one at a time" scheduling |
//!
//! A task name may be reused after the old task is removed.
//! A `TaskId` is allocated from a process-local `u64` counter.
//!
//! The counter is not stored across process restarts, and a `TaskId` is not a UUID.
//! If external systems need a persistent identity, store their own ID next to this one.
//!
//! With the `controller` feature, a submitted task also has a slot key (`ControllerSpec::slot_name`).
//! The slot controls admission only; it is not the same thing as the submission identity.
use ;
/// Process-local allocation counter for task identities.
///
/// Starts at `1`.
/// Like all `AtomicU64::fetch_add` counters, it wraps after `2^64` allocations;
/// reaching that limit is outside normal operation.
static TASK_ID_SEQ: AtomicU64 = new;
/// Opaque process-local identity of one task submission and its run, if admitted.
///
/// A `TaskId` is allocated by Taskvisor and carried on submission and lifecycle [`Event`](crate::Event)s.
/// A controller submission keeps the same id from queueing through admission, execution, and terminal cleanup.
///
/// Rejected work keeps its id even though no task body ran.
///
/// Use it to:
/// - cancel or remove a task by identity,
/// - correlate events for the same submission and run,
/// - keep stable log and metrics references within one process run.
///
/// Do not parse its display output.
/// Use [`get`](Self::get) when you need the numeric value.
/// Numeric order is allocation order, not a causal or time order.
;