Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions probe-plotter/src/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ pub struct Metric<T: Metricable> {
x: *mut T,
}

// Safety: No one besides us and the debug probe has the raw pointer, so we can safely transfer
// Metric to another thread / execution context if T can be safely transferred.
unsafe impl<T> Send for Metric<T> where T: Send + Metricable {}

// Safety: We only allow mutability through exclusive references so there is no risk
// in having multiple shared references to this value across threads/execution contexts
unsafe impl<T> Sync for Metric<T> where T: Sync + Metricable {}

/// Create using [make_metric]
///
/// ```
Expand Down
8 changes: 8 additions & 0 deletions probe-plotter/src/setting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ pub struct Setting<T: Metricable> {
x: *mut T,
}

// Safety: No one besides us and the debug probe has the raw pointer, so we can safely transfer
// Setting to another thread / execution context if T can be safely transferred.
unsafe impl<T> Send for Setting<T> where T: Send + Metricable {}

// Safety: We only allow mutability through exclusive references so there is no risk
// in having multiple shared references to this value across threads/execution contexts
unsafe impl<T> Sync for Setting<T> where T: Sync + Metricable {}

/// Create using [make_setting]
///
/// ```
Expand Down
Loading