Summary:
std::atomic<bool> default constructor doesn't initialize it to
false, so the flag to end the LifoSem.multi_try_wait test was sometimes
set too early. This diff fixes that, makes the test more deterministic,
and also fixes a couple of other benign uninitialized values (so that
they won't be used as prototypes for places where it does matter).
Test Plan: unit tests
Reviewed By: mpawlowski@fb.com
Subscribers: njormrod, lovro
FB internal diff:
D1604508
Tasks:
5336837
while (!go.load()) {
sched_yield();
}
- std::atomic<int> localWork;
+ std::atomic<int> localWork(0);
if (spreaderType == SpreaderType::SHARED) {
for (size_t i = iters; i > 0; --i) {
++*(counters[AccessSpreader<>::current(stripes)]);
while (!go.load()) {
sched_yield();
}
- std::atomic<size_t> localCounter;
- std::atomic<int> localWork;
+ std::atomic<size_t> localCounter(0);
+ std::atomic<int> localWork(0);
for (size_t i = iters; i > 0; --i) {
localCounter++;
for (size_t j = work; j > 0; --j) {
}
};
- std::atomic<bool> consumer_stop;
+ DeterministicAtomic<bool> consumer_stop(false);
int consumed = 0;
auto consumer = [&]{