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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//! Process-wide state: a single declaration site and a single locking policy.
//!
//! Every piece of state that lives for the whole process is declared in this
//! module and listed in the inventory below. Before it existed, each piece came
//! with its own private accessor (`fn response_handlers() -> &'static
//! Mutex<HashMap<..>>`) spread over half a dozen modules, which made both the
//! lifetime rules and the poisoning policy invisible from the call sites.
//!
//! # Inventory
//!
//! | State | Declaration | Key | Written by | Read by | Released |
//! |---|---|---|---|---|---|
//! | Cancel token of the IPC threads | `lib.rs`, [`Global`] | — | unchanged after creation | every dispatch loop, `wait_for_shutdown` | never (process lifetime) |
//! | Registry cancel token | `lib.rs`, [`Global`] | — | unchanged after creation | `publish_until_delivered` | never |
//! | iceoryx2 bootstrap (`Once`) | `lib.rs`, [`Global`] | — | first `init()` | every `init()` | never |
//! | Signal-handling flag | `lib.rs`, `AtomicBool` | — | `init` / `init_without_ctrl_c` | `waitset_signal_handling_mode` | not applicable |
//! | Shared iceoryx2 node | `transport::shared_node`, [`Global`] | — | first port creation | every port creation, observers | never |
//! | In-flight response handlers | `transport::client`, map owned by the channel ports | correlation id | `native_call`, before publishing | response dispatch thread | on the terminal event of the call, or when the call is dropped |
//! | Consumer ports per channel | `transport::client`, [`Locked`] | channel name | `consumer_ports` | `native_call` | never (one set per channel) |
//! | Pending channels | `transport::server`, [`Locked`] | channel name | `register_native_service` | `start_registered_channels` | drained at the end of initialization |
//! | Channels sealed flag | `transport::server`, `AtomicBool` | — | `start_registered_channels` | `register_native_service` | not applicable |
//! | Watched PIDs (liveness) | `node_liveness`, [`Registry`] | pid | `register_node_liveness_watcher` | the shared poller | `unregister_…` or on confirmed death |
//! | Liveness poll interval | `node_liveness`, [`Global`] | — | first read of the env var | every poller tick | never |
//! | Liveness poller started | `node_liveness`, [`Global`] | — | first watcher registration | every registration | never |
//! | IPC cleanup resources | `shutdown`, [`Locked`] | — | `register_ipc_cleanup` | `clear_ipc_cleanup` | at shutdown |
//! | Service locator | `locator`, [`Global`] | — | first `locator()` call | everywhere | never |
//! | Node.js dispatch pointer | `nodejs_dispatch`, [`Global`] | — | gateway startup | ProviderNodeJs dispatch | never |
//! | Notification clock origin | `transport::notify`, [`Global`] | — | first notification | every coalescing check | never |
//!
//! Two raw styles remain on purpose, because they carry no locking policy:
//! `AtomicBool`/`AtomicU64` for flags and counters, and [`Global`] for values
//! that are never mutated after creation. Everything shared and mutated goes
//! through [`Locked`], which owns the single entry point to the mutex.
//!
//! # Poisoning
//!
//! A poisoned lock is recovered by [`crate::sync::lock`], the single
//! implementation of the policy: the guarded values are plain collections
//! updated through short critical sections, so the original panic is what
//! matters, not a second one raised while unwrapping.
use ;
use cratelock;
/// A value initialized once and read for the rest of the process lifetime.
///
/// Use it for singletons that are never mutated after their creation, where a
/// mutex would only add an uncontended lock on every access.
;
/// A `T` shared between threads, created on first use, guarded by one mutex.
///
/// The single entry point is [`Locked::with`], so the lock can never be held
/// beyond the critical section and the poisoning policy stays in one place.
;