diff options
Diffstat (limited to 'storage/innobase/include/lock0lock.h')
-rw-r--r-- | storage/innobase/include/lock0lock.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index c3b802f4284..7542aaae310 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -641,8 +641,8 @@ private: /** mutex proteting the locks */ MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) srw_lock latch; #ifdef UNIV_DEBUG - /** The owner of exclusive latch (0 if none); protected by latch */ - std::atomic<os_thread_id_t> writer{0}; + /** The owner of exclusive latch; protected by latch */ + std::atomic<std::thread::id> writer; /** Number of shared latches */ std::atomic<ulint> readers{0}; #endif @@ -705,14 +705,14 @@ public: { ut_ad(!is_writer()); latch.wr_lock(); - ut_ad(!writer.exchange(os_thread_get_curr_id(), - std::memory_order_relaxed)); + ut_ad(writer.exchange(std::this_thread::get_id(), + std::memory_order_relaxed) == std::thread::id()); } /** Release exclusive lock_sys.latch */ void wr_unlock() { - ut_ad(writer.exchange(0, std::memory_order_relaxed) == - os_thread_get_curr_id()); + ut_ad(writer.exchange(std::thread::id(), std::memory_order_relaxed) == + std::this_thread::get_id()); latch.wr_unlock(); } /** Acquire shared lock_sys.latch */ @@ -720,7 +720,7 @@ public: { ut_ad(!is_writer()); latch.rd_lock(); - ut_ad(!writer.load(std::memory_order_relaxed)); + ut_ad(writer.load(std::memory_order_relaxed) == std::thread::id()); ut_d(readers.fetch_add(1, std::memory_order_relaxed)); } /** Release shared lock_sys.latch */ @@ -737,8 +737,8 @@ public: { ut_ad(!is_writer()); if (!latch.wr_lock_try()) return false; - ut_ad(!writer.exchange(os_thread_get_curr_id(), - std::memory_order_relaxed)); + ut_ad(writer.exchange(std::this_thread::get_id(), + std::memory_order_relaxed) == std::thread::id()); return true; } /** Try to acquire shared lock_sys.latch @@ -747,7 +747,7 @@ public: { ut_ad(!is_writer()); if (!latch.rd_lock_try()) return false; - ut_ad(!writer.load(std::memory_order_relaxed)); + ut_ad(writer.load(std::memory_order_relaxed) == std::thread::id()); ut_d(readers.fetch_add(1, std::memory_order_relaxed)); return true; } @@ -759,7 +759,10 @@ public: #ifdef UNIV_DEBUG /** @return whether the current thread is the lock_sys.latch writer */ bool is_writer() const - { return writer.load(std::memory_order_relaxed) == os_thread_get_curr_id(); } + { + return writer.load(std::memory_order_relaxed) == + std::this_thread::get_id(); + } /** Assert that a lock shard is exclusively latched (by some thread) */ void assert_locked(const lock_t &lock) const; /** Assert that a table lock shard is exclusively latched by this thread */ |