Class UnixFSCircularBlockBuffer
java.lang.Object
dev.getelements.elements.rt.transact.unix.UnixFSCircularBlockBuffer
Given a
ByteBuffer, this slices the buffer into a series of smaller ByteBuffers which represent a
subset of the data. This allows a ByteBuffer to be used by several threads w/ exclusive access to subsections
of the content.
While this structure's behavior is thread safe, care must be taken by the client code to ensure that the data
contained in the block buffer is mutated appropriately. Specifically each UnixFSCircularBlockBuffer.Slice instance returend by this
UnixFSCircularBlockBuffer is not thread safe. Therefore, additional steps must be taken to ensure predictable
behavior when dealing with the individual UnixFSCircularBlockBuffer.Slices of this buffer.
The UnixFSCircularBlockBuffer.View.stream() UnixFSCircularBlockBuffer.View.reverse() methods of this class uses a snapshot of the trailing/leading values
and it is possible that data has changed while iterating. Therefore, code using an iterator must be prepared to
handle such scenarios.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents a slice of the provided byte buffer array.static interfaceRepresents a view of the underlyingUnixFSCircularBlockBuffer. -
Constructor Summary
ConstructorsConstructorDescriptionUnixFSCircularBlockBuffer(UnixFSAtomicLong atomicLong, ByteBuffer buffer, int blockSize) -
Method Summary
Modifier and TypeMethodDescription<StructT extends javolution.io.Struct>
UnixFSCircularBlockBuffer.View<StructT> forStructType(Supplier<StructT> structSuppler) Allows for the creation of aUnixFSCircularBlockBuffer.View<StructT extends javolution.io.Struct>which can represent the underlying data slices as a fixed-sized array ofStructtypes.rawView()Returns a raw-view of the circular block buffer.reset()Resets theUnixFSCircularBlockBuffertoString()
-
Constructor Details
-
UnixFSCircularBlockBuffer
-
-
Method Details
-
reset
Resets theUnixFSCircularBlockBuffer- Returns:
- this instance
-
rawView
Returns a raw-view of the circular block buffer.- Returns:
- the raw view
-
forStructType
public <StructT extends javolution.io.Struct> UnixFSCircularBlockBuffer.View<StructT> forStructType(Supplier<StructT> structSuppler) Allows for the creation of aUnixFSCircularBlockBuffer.View<StructT extends javolution.io.Struct>which can represent the underlying data slices as a fixed-sized array ofStructtypes.- Type Parameters:
StructT- the type of the struct- Parameters:
structSuppler- theUnixFSCircularBlockBuffersupplier- Returns:
- the new typed view
-
toString
-