Better trigger race condition in bin_batching unit test

This commit is contained in:
Shirui Cheng 2024-08-22 21:58:58 -07:00 committed by Qi Wang
parent c7ccb8d7e9
commit 8c54637f8c
1 changed files with 8 additions and 1 deletions

View File

@ -45,9 +45,16 @@ increment_push_failure(size_t push_idx) {
atomic_fetch_add_zu(&push_failure_count, 1, ATOMIC_RELAXED);
} else {
assert_zu_lt(push_idx, 4, "Only 4 elems");
volatile int x = 10000;
volatile size_t x = 10000;
while (--x) {
/* Spin for a while, to try to provoke a failure. */
if (x == push_idx) {
#ifdef _WIN32
SwitchToThread();
#else
sched_yield();
#endif
}
}
}
}