Class UnixFSCircularBlockBuffer
java.lang.Object
dev.getelements.elements.rt.transact.unix.UnixFSCircularBlockBuffer
Given a
ByteBuffer
, this slices the buffer into a series of smaller ByteBuffer
s 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.Slice
s 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 TypeClassDescriptionclass
Represents a slice of the provided byte buffer array.static interface
Represents 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 ofStruct
types.rawView()
Returns a raw-view of the circular block buffer.reset()
Resets theUnixFSCircularBlockBuffer
toString()
-
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 ofStruct
types.- Type Parameters:
StructT
- the type of the struct- Parameters:
structSuppler
- theUnixFSCircularBlockBuffer
supplier- Returns:
- the new typed view
-
toString
-