2 * Copyright 2017 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
7 #ifndef CROS_GRALLOC_SPINLOCK_H
8 #define CROS_GRALLOC_SPINLOCK_H
16 while (atomic_lock_.test_and_set(std::memory_order_acquire)) {
21 atomic_lock_.clear(std::memory_order_release);
25 std::atomic_flag atomic_lock_ = ATOMIC_FLAG_INIT;
28 class ScopedSpinLock {
30 explicit ScopedSpinLock(SpinLock& lock) : lock_(lock) {
47 #define SCOPED_SPIN_LOCK(X) \
48 ScopedSpinLock lock(X);
59 #define SCOPED_SPIN_LOCK(X) ((void)0)
62 #endif // PUBLIC_SPINLOCK_H_