Skip to content

Commit

Permalink
Merge pull request #84 from ikbuibui/cv_changes
Browse files Browse the repository at this point in the history
Improve cv
  • Loading branch information
ikbuibui authored Jul 29, 2024
2 parents a75c587 + 1ce02e8 commit 94894e4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions redGrapes/sync/cv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ namespace redGrapes
}
}

should_wait.store(true);
should_wait.store(true, std::memory_order_release);
}

bool notify()
{
bool w = true;
should_wait.compare_exchange_strong(w, false, std::memory_order_release);

// TODO: check this optimization
// if( ! busy.test_and_set(std::memory_order_acquire) )
bool expected = true;
if(should_wait
.compare_exchange_strong(expected, false, std::memory_order_release, std::memory_order_relaxed))
{
std::unique_lock<std::mutex> l(m);
// TODO: check this optimization
// if( ! busy.test_and_set(std::memory_order_acquire) )
std::unique_lock<CVMutex> l(m);
cv.notify_all();
return true;
}

return w;
return false;
}
};

Expand Down

0 comments on commit 94894e4

Please sign in to comment.