Skip to content

Commit

Permalink
Fix race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Pansysk75 committed Sep 9, 2024
1 parent 5ed299c commit c008395
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,19 @@ namespace hpx::util {
pointer allocate(size_type n)
{
pointer p;
if (data.empty())
std::pair<T*, size_type> pair;
if (data.pop(pair))
{
p = pair.first;
}
else
{
p = traits::allocate(alloc, n);
if (p == nullptr)
{
throw std::bad_alloc();
}
}
else
{
std::pair<T*, size_type> pair;
data.pop(pair);
p = pair.first;
}

++allocated;
return p;
Expand Down

0 comments on commit c008395

Please sign in to comment.