]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/table/scoped_arena_iterator.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style license that can be
7 // found in the LICENSE file. See the AUTHORS file for names of contributors.
10 #include "table/internal_iterator.h"
11 #include "port/port.h"
14 class ScopedArenaIterator
{
16 void reset(InternalIterator
* iter
) ROCKSDB_NOEXCEPT
{
17 if (iter_
!= nullptr) {
18 iter_
->~InternalIterator();
25 explicit ScopedArenaIterator(InternalIterator
* iter
= nullptr)
28 ScopedArenaIterator(const ScopedArenaIterator
&) = delete;
29 ScopedArenaIterator
& operator=(const ScopedArenaIterator
&) = delete;
31 ScopedArenaIterator(ScopedArenaIterator
&& o
) ROCKSDB_NOEXCEPT
{
36 ScopedArenaIterator
& operator=(ScopedArenaIterator
&& o
) ROCKSDB_NOEXCEPT
{
42 InternalIterator
* operator->() { return iter_
; }
43 InternalIterator
* get() { return iter_
; }
45 void set(InternalIterator
* iter
) { reset(iter
); }
47 InternalIterator
* release() {
48 assert(iter_
!= nullptr);
54 ~ScopedArenaIterator() {
59 InternalIterator
* iter_
;
61 } // namespace rocksdb