OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <gperftools/spin_lock_wrapper.h> |
| 6 |
| 7 #include <new> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/spinlock.h" |
| 11 #include <gperftools/custom_allocator.h> |
| 12 |
| 13 SpinLockWrapper::SpinLockWrapper() { |
| 14 CHECK(CustomAllocator::IsInitialized()); |
| 15 lock_ = new(CustomAllocator::Allocate(sizeof(SpinLock))) SpinLock; |
| 16 } |
| 17 |
| 18 SpinLockWrapper::~SpinLockWrapper() { |
| 19 lock_->~SpinLock(); |
| 20 CustomAllocator::Free(lock_, sizeof(*lock_)); |
| 21 lock_ = nullptr; |
| 22 } |
| 23 |
| 24 void SpinLockWrapper::Lock() { |
| 25 lock_->Lock(); |
| 26 } |
| 27 |
| 28 void SpinLockWrapper::Unlock() { |
| 29 lock_->Unlock(); |
| 30 } |
OLD | NEW |