[K/N] Avoid inlining of ignored check on external call
This commit is contained in:
committed by
Space Team
parent
6ff282eca3
commit
c4e2901a1d
@@ -36,20 +36,23 @@ class SpinLock;
|
|||||||
template <>
|
template <>
|
||||||
class SpinLock<MutexThreadStateHandling::kIgnore> : private Pinned {
|
class SpinLock<MutexThreadStateHandling::kIgnore> : private Pinned {
|
||||||
public:
|
public:
|
||||||
// No need to check for external calls, because we explicitly ignore thread state.
|
void lock() noexcept {
|
||||||
NO_EXTERNAL_CALLS_CHECK void lock() noexcept {
|
|
||||||
while(flag_.test_and_set(std::memory_order_acquire)) {
|
while(flag_.test_and_set(std::memory_order_acquire)) {
|
||||||
std::this_thread::yield();
|
yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// No need to check for external calls, because we explicitly ignore thread state.
|
void unlock() noexcept {
|
||||||
NO_EXTERNAL_CALLS_CHECK void unlock() noexcept {
|
|
||||||
flag_.clear(std::memory_order_release);
|
flag_.clear(std::memory_order_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::atomic_flag flag_ = ATOMIC_FLAG_INIT;
|
std::atomic_flag flag_ = ATOMIC_FLAG_INIT;
|
||||||
|
|
||||||
|
// No need to check for external calls, because we explicitly ignore thread state.
|
||||||
|
static NO_EXTERNAL_CALLS_CHECK NO_INLINE void yield() {
|
||||||
|
std::this_thread::yield();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|||||||
Reference in New Issue
Block a user