Skip to content

Add bounds for WorkerLocal's Send and Sync #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2021
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rustc-rayon"
# Reminder to update html_rool_url in lib.rs when updating version
version = "0.3.0"
version = "0.3.1"
authors = ["Niko Matsakis <niko@alum.mit.edu>",
"Josh Stone <cuviper@gmail.com>"]
description = "Simple work-stealing parallelism for Rust - fork for rustc"
Expand Down
2 changes: 1 addition & 1 deletion rayon-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rustc-rayon-core"
version = "0.3.0" # reminder to update html_root_url attribute
version = "0.3.1" # reminder to update html_root_url attribute
authors = ["Niko Matsakis <niko@alum.mit.edu>",
"Josh Stone <cuviper@gmail.com>"]
description = "Core APIs for Rayon - fork for rustc"
Expand Down
10 changes: 7 additions & 3 deletions rayon-core/src/worker_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ pub struct WorkerLocal<T> {
registry: Arc<Registry>,
}

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

impl<T> WorkerLocal<T> {
/// Creates a new worker local where the `initial` closure computes the
Expand Down Expand Up @@ -60,7 +62,9 @@ impl<T> WorkerLocal<Vec<T>> {

impl<T: fmt::Debug> fmt::Debug for WorkerLocal<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt(&self.locals, f)
f.debug_struct("WorkerLocal")
.field("registry", &self.registry.id())
.finish()
}
}

Expand Down