Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Created March 21, 2019 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcrichton/4c7e0862a8cfc06a2151a9ba6e47ecf3 to your computer and use it in GitHub Desktop.
Save alexcrichton/4c7e0862a8cfc06a2151a9ba6e47ecf3 to your computer and use it in GitHub Desktop.
diff --git a/rayon-core/src/registry.rs b/rayon-core/src/registry.rs
index 63d8a31..ced0b9c 100644
--- a/rayon-core/src/registry.rs
+++ b/rayon-core/src/registry.rs
@@ -589,6 +589,13 @@ impl WorkerThread {
});
}
+ unsafe fn unset_current() {
+ WORKER_THREAD_STATE.with(|t| {
+ assert!(!t.get().is_null());
+ t.set(std::ptr::null());
+ });
+ }
+
/// Returns the registry that owns this worker thread.
pub fn registry(&self) -> &Arc<Registry> {
&self.registry
@@ -789,6 +796,7 @@ unsafe fn main_loop(
}
// We're already exiting the thread, there's nothing else to do.
}
+ WorkerThread::unset_current();
}
/// If already in a worker-thread, just execute `op`. Otherwise,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment