Commit dc7ef7db authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

base/allocator: Add a missing LOCKABLE annotation to SpinLock

SpinLock class is missing LOCKABLE annotation, so adds it.
Also adds other lock function annotations.

Change-Id: I9c75b6bd41aa63bd3a0350342ed4476c92174ca1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505690Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarBenoit L <lizeb@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821800}
parent ee622240
......@@ -55,24 +55,24 @@ class SCOPED_LOCKABLE ScopedUnlockGuard {
#if !defined(PA_HAS_SPINNING_MUTEX)
// Spinlock. Do not use, to be removed. crbug.com/1061437.
class BASE_EXPORT SpinLock {
class LOCKABLE BASE_EXPORT SpinLock {
public:
constexpr SpinLock() = default;
~SpinLock() = default;
ALWAYS_INLINE void Acquire() {
ALWAYS_INLINE void Acquire() EXCLUSIVE_LOCK_FUNCTION() {
if (LIKELY(!lock_.exchange(true, std::memory_order_acquire)))
return;
AcquireSlow();
}
ALWAYS_INLINE bool Try() {
ALWAYS_INLINE bool Try() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
// Faster than simple CAS.
return !lock_.load(std::memory_order_relaxed) &&
!lock_.exchange(true, std::memory_order_acquire);
}
ALWAYS_INLINE void Release() {
ALWAYS_INLINE void Release() UNLOCK_FUNCTION() {
lock_.store(false, std::memory_order_release);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment