| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/synchronization/spin_lock.h" | 5 #include "base/allocator/partition_allocator/spin_lock.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
| 10 #include <sched.h> | 10 #include <sched.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 // The YIELD_PROCESSOR macro wraps an architecture specific-instruction that | 13 // The YIELD_PROCESSOR macro wraps an architecture specific-instruction that |
| 14 // informs the processor we're in a busy wait, so it can handle the branch more | 14 // informs the processor we're in a busy wait, so it can handle the branch more |
| 15 // intelligently and e.g. reduce power to our core or give more resources to the | 15 // intelligently and e.g. reduce power to our core or give more resources to the |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Give the OS a chance to schedule something on this core. | 75 // Give the OS a chance to schedule something on this core. |
| 76 YIELD_THREAD; | 76 YIELD_THREAD; |
| 77 } while (lock_.load(std::memory_order_relaxed)); | 77 } while (lock_.load(std::memory_order_relaxed)); |
| 78 } while (UNLIKELY(lock_.exchange(true, std::memory_order_acquire))); | 78 } while (UNLIKELY(lock_.exchange(true, std::memory_order_acquire))); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace subtle | 81 } // namespace subtle |
| 82 } // namespace base | 82 } // namespace base |
| OLD | NEW |