Skip to content

Commit b15e5cb

Browse files
authored
Merge branch 'main' into manually-add-symbols
2 parents 743995d + e391a35 commit b15e5cb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

probe-plotter/src/metric.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ pub struct Metric<T: Metricable> {
1515
x: *mut T,
1616
}
1717

18-
unsafe impl<T: Metricable> Send for Metric<T> {}
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 {}
1921

2022
/// Create using [make_metric]
2123
///

probe-plotter/src/setting.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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
/// ```

0 commit comments

Comments
 (0)