Skip to content

Commit 3e5912c

Browse files
committed
Ability to terminate thread-pool upon shutdown
While `.terminate()` will leave the thread-pool in corrupt state, it helps debugging and testing.
1 parent f45eee8 commit 3e5912c

File tree

1 file changed

+7
-0
lines changed
  • rayon-core/src/thread_pool

1 file changed

+7
-0
lines changed

rayon-core/src/thread_pool/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,13 @@ impl ThreadPool {
277277
// We assert that `self.registry` has not terminated.
278278
unsafe { spawn::spawn_fifo_in(op, &self.registry) }
279279
}
280+
281+
/// Terminates the threads, renders the threadpool unusable.
282+
/// This is useful for testing (miri) if the thread-pool is static.
283+
/// It should be used upon shutdown only
284+
pub unsafe fn terminate(&self) {
285+
self.registry.terminate();
286+
}
280287
}
281288

282289
impl Drop for ThreadPool {

0 commit comments

Comments
 (0)