Skip to content

Commit

Permalink
Fix race condition in circular buffer simulation test
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomsonTan committed Jul 31, 2021
1 parent 5414ebe commit 901e3d0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sdk/test/common/circular_buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ void RunNumberConsumer(CircularBuffer<uint32_t> &buffer,
{
while (true)
{
auto allotment = buffer.Peek();
if (exit && allotment.empty())
if (exit && buffer.Peek().empty())
{
return;
}
auto n = std::uniform_int_distribution<size_t>{0, allotment.size()}(RandomNumberGenerator);
auto n = std::uniform_int_distribution<size_t>{0, buffer.Peek().size()}(RandomNumberGenerator);
buffer.Consume(n, [&](CircularBufferRange<AtomicUniquePtr<uint32_t>> range) noexcept {
assert(range.size() == n);
range.ForEach([&](AtomicUniquePtr<uint32_t> &ptr) noexcept {
Expand Down

0 comments on commit 901e3d0

Please sign in to comment.