diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-16 18:40:15 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-16 18:40:15 +0000 |
commit | f1fae3cd1b9492cf9411dffd3c486b9672d8cc76 (patch) | |
tree | bee5d8b2528e714149d399163519f0fa35ec532b /third_party/base/allocator/partition_allocator/spin_lock.h | |
parent | 1b6fcaad0722fb586620efc974726dee3fb0f80f (diff) | |
download | pdfium-f1fae3cd1b9492cf9411dffd3c486b9672d8cc76.tar.xz |
Update PartitionAlloc from Chromium at r599712.
BUG=pdfium:1170
Change-Id: I0f8dfb3d517beaa682a9ca7ad4831c5a7a10dc3b
Reviewed-on: https://pdfium-review.googlesource.com/c/44073
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'third_party/base/allocator/partition_allocator/spin_lock.h')
-rw-r--r-- | third_party/base/allocator/partition_allocator/spin_lock.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/third_party/base/allocator/partition_allocator/spin_lock.h b/third_party/base/allocator/partition_allocator/spin_lock.h index 7a42a29c4e..5613fd130c 100644 --- a/third_party/base/allocator/partition_allocator/spin_lock.h +++ b/third_party/base/allocator/partition_allocator/spin_lock.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_SPIN_LOCK_H -#define BASE_ALLOCATOR_PARTITION_ALLOCATOR_SPIN_LOCK_H +#ifndef THIRD_PARTY_BASE_ALLOCATOR_PARTITION_ALLOCATOR_SPIN_LOCK_H_ +#define THIRD_PARTY_BASE_ALLOCATOR_PARTITION_ALLOCATOR_SPIN_LOCK_H_ #include <atomic> #include <memory> @@ -17,16 +17,14 @@ // intended only for very short duration locks and assume a system with multiple // cores. For any potentially longer wait you should use a real lock, such as // |base::Lock|. -// -// |SpinLock|s MUST be globals. Using them as (e.g.) struct/class members will -// result in an uninitialized lock, which is dangerously incorrect. - namespace pdfium { namespace base { namespace subtle { -class SpinLock { +class BASE_EXPORT SpinLock { public: + constexpr SpinLock() = default; + ~SpinLock() = default; using Guard = std::lock_guard<SpinLock>; ALWAYS_INLINE void lock() { @@ -42,13 +40,13 @@ class SpinLock { private: // This is called if the initial attempt to acquire the lock fails. It's // slower, but has a much better scheduling and power consumption behavior. - BASE_EXPORT void LockSlow(); + void LockSlow(); - std::atomic_int lock_; + std::atomic_int lock_{0}; }; } // namespace subtle } // namespace base } // namespace pdfium -#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_SPIN_LOCK_H +#endif // THIRD_PARTY_BASE_ALLOCATOR_PARTITION_ALLOCATOR_SPIN_LOCK_H_ |