Skip to content

Commit

Permalink
Ability to terminate thread-pool upon shutdown
Browse files Browse the repository at this point in the history
While `.terminate()` will leave the thread-pool in corrupt state, it helps debugging and testing.
  • Loading branch information
alippai committed Nov 29, 2021
1 parent f45eee8 commit 3e5912c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rayon-core/src/thread_pool/mod.rs
Expand Up @@ -277,6 +277,13 @@ impl ThreadPool {
// We assert that `self.registry` has not terminated.
unsafe { spawn::spawn_fifo_in(op, &self.registry) }
}

/// Terminates the threads, renders the threadpool unusable.
/// This is useful for testing (miri) if the thread-pool is static.
/// It should be used upon shutdown only
pub unsafe fn terminate(&self) {
self.registry.terminate();
}
}

impl Drop for ThreadPool {
Expand Down

0 comments on commit 3e5912c

Please sign in to comment.