| Index: third_party/tcmalloc/chromium/src/spin_lock_wrapper.cc
|
| diff --git a/third_party/tcmalloc/chromium/src/spin_lock_wrapper.cc b/third_party/tcmalloc/chromium/src/spin_lock_wrapper.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..37fa4daa6dd50682209442888871a5be8ff32e9a
|
| --- /dev/null
|
| +++ b/third_party/tcmalloc/chromium/src/spin_lock_wrapper.cc
|
| @@ -0,0 +1,30 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <gperftools/spin_lock_wrapper.h>
|
| +
|
| +#include <new>
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/spinlock.h"
|
| +#include <gperftools/custom_allocator.h>
|
| +
|
| +SpinLockWrapper::SpinLockWrapper() {
|
| + CHECK(CustomAllocator::IsInitialized());
|
| + lock_ = new(CustomAllocator::Allocate(sizeof(SpinLock))) SpinLock;
|
| +}
|
| +
|
| +SpinLockWrapper::~SpinLockWrapper() {
|
| + lock_->~SpinLock();
|
| + CustomAllocator::Free(lock_, sizeof(*lock_));
|
| + lock_ = nullptr;
|
| +}
|
| +
|
| +void SpinLockWrapper::Lock() {
|
| + lock_->Lock();
|
| +}
|
| +
|
| +void SpinLockWrapper::Unlock() {
|
| + lock_->Unlock();
|
| +}
|
|
|