intrusive_heap.cc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2018 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. #include "base/containers/intrusive_heap.h"
  5. #include "base/check.h"
  6. #include "base/memory/ptr_util.h"
  7. namespace base {
  8. ////////////////////////////////////////////////////////////////////////////////
  9. // HeapHandle
  10. // static
  11. HeapHandle HeapHandle::Invalid() {
  12. return HeapHandle();
  13. }
  14. ////////////////////////////////////////////////////////////////////////////////
  15. // InternalHeapHandleStorage
  16. InternalHeapHandleStorage::InternalHeapHandleStorage()
  17. : handle_(new HeapHandle()) {}
  18. InternalHeapHandleStorage::InternalHeapHandleStorage(
  19. InternalHeapHandleStorage&& other) noexcept
  20. : handle_(std::move(other.handle_)) {
  21. DCHECK(intrusive_heap::IsInvalid(other.handle_));
  22. }
  23. InternalHeapHandleStorage::~InternalHeapHandleStorage() = default;
  24. InternalHeapHandleStorage& InternalHeapHandleStorage::operator=(
  25. InternalHeapHandleStorage&& other) noexcept {
  26. handle_ = std::move(other.handle_);
  27. DCHECK(intrusive_heap::IsInvalid(other.handle_));
  28. return *this;
  29. }
  30. void InternalHeapHandleStorage::swap(
  31. InternalHeapHandleStorage& other) noexcept {
  32. std::swap(handle_, other.handle_);
  33. }
  34. } // namespace base