Skip to content

Commit 78c54a5

Browse files
martijnvelscopybara-github
authored andcommitted
Minor refactor to num_threads in deadlock test
PiperOrigin-RevId: 817191256 Change-Id: I3b7aa6f189a9d20831af66c7ccffacd03235b3bf
1 parent fc4481e commit 78c54a5

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

absl/base/spinlock_test_common.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,13 @@ TEST(SpinLockWithThreads, DoesNotDeadlock) {
271271
}
272272
};
273273

274+
int num_threads = base_internal::NumCPUs() * 2;
274275
SpinLock stack_cooperative_spinlock;
275276
SpinLock stack_noncooperative_spinlock(base_internal::SCHEDULE_KERNEL_ONLY);
276-
Helper::DeadlockTest(&stack_cooperative_spinlock,
277-
base_internal::NumCPUs() * 2);
278-
Helper::DeadlockTest(&stack_noncooperative_spinlock,
279-
base_internal::NumCPUs() * 2);
280-
Helper::DeadlockTest(&static_cooperative_spinlock,
281-
base_internal::NumCPUs() * 2);
282-
Helper::DeadlockTest(&static_noncooperative_spinlock,
283-
base_internal::NumCPUs() * 2);
277+
Helper::DeadlockTest(&stack_cooperative_spinlock, num_threads);
278+
Helper::DeadlockTest(&stack_noncooperative_spinlock, num_threads);
279+
Helper::DeadlockTest(&static_cooperative_spinlock, num_threads);
280+
Helper::DeadlockTest(&static_noncooperative_spinlock, num_threads);
284281
}
285282

286283
TEST(SpinLockTest, IsCooperative) {

0 commit comments

Comments
 (0)