Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mjp41 committed Jun 24, 2024
1 parent 2f91379 commit 1fdf924
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/snmalloc/ds/combininglock.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ namespace snmalloc
*/
class CombineLockNode
{
template<typename F>
friend class CombineLockNodeTempl;

enum class LockStatus
{
// The work for this node has not been completed.
Expand Down Expand Up @@ -70,10 +73,9 @@ namespace snmalloc
status.store(s, std::memory_order_release);
}

public:
constexpr CombineLockNode(void (*f)(CombineLockNode*)) : f_raw(f) {}

void attach(CombiningLock& lock)
SNMALLOC_FAST_PATH void attach(CombiningLock& lock)
{
// Test if no one is waiting
if (lock.head.load(std::memory_order_relaxed) == nullptr)
Expand All @@ -90,7 +92,11 @@ namespace snmalloc
return;
}
}
attach_slow(lock);
}

SNMALLOC_SLOW_PATH void attach_slow(CombiningLock& lock)
{
// There is contention for the lock, we need to add our work to the
// queue of pending work
auto prev = lock.head.exchange(this, std::memory_order_acq_rel);
Expand Down Expand Up @@ -151,7 +157,10 @@ namespace snmalloc
// queue.
auto curr_c = curr;
if (lock.head.compare_exchange_strong(
curr_c, nullptr, std::memory_order_acq_rel))
curr_c,
nullptr,
std::memory_order_release,
std::memory_order_relaxed))
{
// Queue was successfully closed.
// Notify last element the work was completed.
Expand Down

0 comments on commit 1fdf924

Please sign in to comment.