Skip to content

Commit ecf4e3c

Browse files
authored
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 ecf4e3c

File tree

1 file changed

+8
-1
lines changed
  • rayon-core/src/thread_pool

1 file changed

+8
-1
lines changed

rayon-core/src/thread_pool/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,18 @@ 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 fn terminate(&mut self) {
285+
self.registry.terminate();
286+
}
280287
}
281288

282289
impl Drop for ThreadPool {
283290
fn drop(&mut self) {
284-
self.registry.terminate();
291+
self.terminate();
285292
}
286293
}
287294

0 commit comments

Comments
 (0)