diff --git a/storage/innobase/include/ib0mutex.h b/storage/innobase/include/ib0mutex.h index 8c2e6127b77..0844c72ee84 100644 --- a/storage/innobase/include/ib0mutex.h +++ b/storage/innobase/include/ib0mutex.h @@ -532,15 +532,16 @@ struct TTASEventMutex { @return true on success */ bool try_lock() UNIV_NOTHROW { bool expected = false; - return (m_lock_word.compare_exchange_strong(expected, true)); + return (m_lock_word.compare_exchange_strong(expected, true, + std::memory_order_acq_rel)); } /** Release the mutex. */ void exit() UNIV_NOTHROW { - m_lock_word.store(false); - std::atomic_thread_fence(std::memory_order_acquire); - - if (m_waiters.load(std::memory_order_acquire)) { + m_lock_word.store(false, std::memory_order_release); + bool expected = true; + if (m_waiters.compare_exchange_strong(expected, false, + std::memory_order_acq_rel)) { signal(); } } @@ -672,21 +673,11 @@ struct TTASEventMutex { m_policy.add(n_spins, n_waits); } - /** @return the value of the m_waiters flag */ - lock_word_t waiters() UNIV_NOTHROW { - return (m_waiters.load(std::memory_order_relaxed)); - } - /** Note that there are threads waiting on the mutex */ void set_waiters() UNIV_NOTHROW { m_waiters.store(true, std::memory_order_release); } - /** Note that there are no threads waiting on the mutex */ - void clear_waiters() UNIV_NOTHROW { - m_waiters.store(false, std::memory_order_release); - } - /** Wakeup any waiting thread(s). */ void signal() UNIV_NOTHROW; diff --git a/storage/innobase/include/ut0mutex.ic b/storage/innobase/include/ut0mutex.ic index 6b3ec99c617..8f74c46acbf 100644 --- a/storage/innobase/include/ut0mutex.ic +++ b/storage/innobase/include/ut0mutex.ic @@ -95,8 +95,6 @@ bool TTASEventMutex::wait(const char *filename, uint32_t line, template