Fix a possible test hang in runtime::test_shared_buffer_sweep (#25545)
* Fix a possible test hang in runtime::test_shared_buffer_sweep The test may hang if the total number of threads it wants to start is greater than the number of threads configured in the rayon threadpool. Check to avoid this situation from happening. * Incorporate comment from Xiang Zhu, using std::cmp::min() to simplify the code
This commit is contained in:
parent
d4e7ebf4f8
commit
4b1dd0f921
|
@ -844,7 +844,9 @@ pub mod tests {
|
|||
|
||||
let parallel_reader = reader_ct > 2;
|
||||
let handle = if parallel_reader {
|
||||
let threads = 8;
|
||||
// Avoid to create more than the number of threads available in the
|
||||
// current rayon threadpool. Deadlock could happen otherwise.
|
||||
let threads = std::cmp::min(8, rayon::current_num_threads());
|
||||
Some({
|
||||
let parallel = (0..threads)
|
||||
.into_iter()
|
||||
|
|
Loading…
Reference in New Issue