• Marko Mäkelä's avatar
    MDEV-26467 Unnecessary compare-and-swap loop in srw_mutex · a73eedbf
    Marko Mäkelä authored
    srw_mutex::wait_and_lock(): In the spin loop, we will try to poll
    for non-conflicting lock word state by reads, avoiding any writes.
    We invoke explicit std::atomic_thread_fence(std::memory_order_acquire)
    before returning. The individual operations on the lock word
    can use memory_order_relaxed.
    
    srw_mutex::lock: Document that the value for a single writer is
    HOLDER+1 instead of HOLDER.
    
    srw_mutex::wr_lock_try(), srw_mutex::wr_unlock(): Adjust the value
    of the lock word of a single writer from HOLDER to HOLDER+1.
    a73eedbf
srw_lock.cc 10.8 KB