Skip to content

Commit c8ec88d

Browse files
authored
Merge pull request #8 from ammaraskar/rustc
Add bounds for WorkerLocal's Send and Sync
2 parents ae7bbbd + 623ac39 commit c8ec88d

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc-rayon"
33
# Reminder to update html_rool_url in lib.rs when updating version
4-
version = "0.3.0"
4+
version = "0.3.1"
55
authors = ["Niko Matsakis <[email protected]>",
66
"Josh Stone <[email protected]>"]
77
description = "Simple work-stealing parallelism for Rust - fork for rustc"

rayon-core/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustc-rayon-core"
3-
version = "0.3.0" # reminder to update html_root_url attribute
3+
version = "0.3.1" # reminder to update html_root_url attribute
44
authors = ["Niko Matsakis <[email protected]>",
55
"Josh Stone <[email protected]>"]
66
description = "Core APIs for Rayon - fork for rustc"

rayon-core/src/worker_local.rs

+7-3
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
@@ -60,7 +62,9 @@ impl<T> WorkerLocal<Vec<T>> {
6062

6163
impl<T: fmt::Debug> fmt::Debug for WorkerLocal<T> {
6264
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
63-
fmt::Debug::fmt(&self.locals, f)
65+
f.debug_struct("WorkerLocal")
66+
.field("registry", &self.registry.id())
67+
.finish()
6468
}
6569
}
6670

0 commit comments

Comments
 (0)