From e6e7feb985b4c1d3f2e643433d266f67828a2c8d Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Tue, 13 Sep 2022 13:37:12 +0000 Subject: [PATCH] [K/N] Do not check for external calls in SpinLock Merge-request: KT-MR-7099 Merged-by: Alexander Shabalin --- kotlin-native/runtime/src/main/cpp/Mutex.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kotlin-native/runtime/src/main/cpp/Mutex.hpp b/kotlin-native/runtime/src/main/cpp/Mutex.hpp index f75352d51b2..ea3bc2571ca 100644 --- a/kotlin-native/runtime/src/main/cpp/Mutex.hpp +++ b/kotlin-native/runtime/src/main/cpp/Mutex.hpp @@ -36,13 +36,15 @@ class SpinLock; template <> class SpinLock : private Pinned { public: - void lock() noexcept { + // No need to check for external calls, because we explicitly ignore thread state. + NO_EXTERNAL_CALLS_CHECK void lock() noexcept { while(flag_.test_and_set(std::memory_order_acquire)) { std::this_thread::yield(); } } - void unlock() noexcept { + // No need to check for external calls, because we explicitly ignore thread state. + NO_EXTERNAL_CALLS_CHECK void unlock() noexcept { flag_.clear(std::memory_order_release); }