Skip to content

Commit 912cc49

Browse files
committed
Add bounds for WorkerLocal's Send and Sync
1 parent ae7bbbd commit 912cc49

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rayon-core/src/worker_local.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ pub struct WorkerLocal<T> {
1515
registry: Arc<Registry>,
1616
}
1717

18-
unsafe impl<T> Send for WorkerLocal<T> {}
19-
unsafe impl<T> Sync for WorkerLocal<T> {}
18+
/// We prevent concurrent access to the underlying value in the
19+
/// Deref impl, thus any values safe to send across threads can
20+
/// be used with WorkerLocal.
21+
unsafe impl<T: Send> Sync for WorkerLocal<T> {}
2022

2123
impl<T> WorkerLocal<T> {
2224
/// Creates a new worker local where the `initial` closure computes the

0 commit comments

Comments
 (0)