]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | // This source code is licensed under the BSD-style license found in the | |
3 | // LICENSE file in the root directory of this source tree. An additional grant | |
4 | // of patent rights can be found in the PATENTS file in the same directory. | |
5 | ||
6 | package org.rocksdb; | |
7 | ||
8 | /** | |
9 | * RocksObject is an implementation of {@link AbstractNativeReference} which | |
10 | * has an immutable and therefore thread-safe reference to the underlying | |
11 | * native C++ RocksDB object. | |
12 | * <p> | |
13 | * RocksObject is the base-class of almost all RocksDB classes that have a | |
14 | * pointer to some underlying native C++ {@code rocksdb} object.</p> | |
15 | * <p> | |
16 | * The use of {@code RocksObject} should always be preferred over | |
17 | * {@link RocksMutableObject}.</p> | |
18 | */ | |
19 | public abstract class RocksObject extends AbstractImmutableNativeReference { | |
20 | ||
21 | /** | |
22 | * An immutable reference to the value of the C++ pointer pointing to some | |
23 | * underlying native RocksDB C++ object. | |
24 | */ | |
25 | protected final long nativeHandle_; | |
26 | ||
27 | protected RocksObject(final long nativeHandle) { | |
28 | super(true); | |
29 | this.nativeHandle_ = nativeHandle; | |
30 | } | |
31 | ||
32 | /** | |
33 | * Deletes underlying C++ object pointer. | |
34 | */ | |
35 | @Override | |
36 | protected void disposeInternal() { | |
37 | disposeInternal(nativeHandle_); | |
38 | } | |
39 | ||
40 | protected abstract void disposeInternal(final long handle); | |
41 | } |