java.lang.Object
org.apache.lucene.store.ByteBufferGuard
A guard that is created for every
ByteBufferIndexInput
that tries on best effort to
reject any access to the ByteBuffer
behind, once it is unmapped. A single instance of
this is used for the original and all clones, so once the original is closed and unmapped all
clones also throw AlreadyClosedException
, triggered by a NullPointerException
.
This code tries to hopefully flush any CPU caches using a store-store barrier. It also yields the current thread to give other threads a chance to finish in-flight requests...
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
Pass in an implementation of this interface to cleanup ByteBuffers. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteBufferGuard.BufferCleaner
private boolean
Not volatile; see comments on visibility below!private final String
-
Constructor Summary
ConstructorsConstructorDescriptionByteBufferGuard
(String resourceDescription, ByteBufferGuard.BufferCleaner cleaner) Creates an instance to be used for a singleByteBufferIndexInput
which must be shared by all of its clones. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
byte
getByte
(ByteBuffer receiver) byte
getByte
(ByteBuffer receiver, int pos) void
getBytes
(ByteBuffer receiver, byte[] dst, int offset, int length) void
getFloats
(FloatBuffer receiver, float[] dst, int offset, int length) int
getInt
(ByteBuffer receiver) int
getInt
(ByteBuffer receiver, int pos) void
long
getLong
(ByteBuffer receiver) long
getLong
(ByteBuffer receiver, int pos) void
getLongs
(LongBuffer receiver, long[] dst, int offset, int length) short
getShort
(ByteBuffer receiver) short
getShort
(ByteBuffer receiver, int pos) void
invalidateAndUnmap
(ByteBuffer... bufs) Invalidates this guard and unmaps (if supported).boolean
-
Field Details
-
resourceDescription
-
cleaner
-
invalidated
private boolean invalidatedNot volatile; see comments on visibility below!
-
-
Constructor Details
-
ByteBufferGuard
Creates an instance to be used for a singleByteBufferIndexInput
which must be shared by all of its clones.
-
-
Method Details
-
invalidateAndUnmap
Invalidates this guard and unmaps (if supported).- Throws:
IOException
-
isInvalidated
public boolean isInvalidated() -
ensureValid
private void ensureValid() -
getBytes
-
getByte
-
getShort
-
getInt
-
getLong
-
getByte
-
getShort
-
getInt
-
getLong
-
getLongs
-
getInts
-
getFloats
-