File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ pub struct Metric<T: Metricable> {
1515 x : * mut T ,
1616}
1717
18+ // Safety: No one besides us and the debug probe has the raw pointer, so we can safely transfer
19+ // Metric to another thread / execution context if T can be safely transferred.
20+ unsafe impl < T > Send for Metric < T > where T : Send + Metricable { }
21+
22+ // Safety: We only allow mutability through exclusive references so there is no risk
23+ // in having multiple shared references to this value across threads/execution contexts
24+ unsafe impl < T > Sync for Metric < T > where T : Sync + Metricable { }
25+
1826/// Create using [make_metric]
1927///
2028/// ```
Original file line number Diff line number Diff line change @@ -6,6 +6,14 @@ pub struct Setting<T: Metricable> {
66 x : * mut T ,
77}
88
9+ // Safety: No one besides us and the debug probe has the raw pointer, so we can safely transfer
10+ // Setting to another thread / execution context if T can be safely transferred.
11+ unsafe impl < T > Send for Setting < T > where T : Send + Metricable { }
12+
13+ // Safety: We only allow mutability through exclusive references so there is no risk
14+ // in having multiple shared references to this value across threads/execution contexts
15+ unsafe impl < T > Sync for Setting < T > where T : Sync + Metricable { }
16+
917/// Create using [make_setting]
1018///
1119/// ```
You can’t perform that action at this time.
0 commit comments