Package com.jogamp.common.nio
Class CachedBufferFactory
java.lang.Object
com.jogamp.common.nio.CachedBufferFactory
Buffer factory attempting to reduce buffer creation overhead.
Direct ByteBuffers must be page aligned which increases creation overhead of
small buffers significantly.
This factory can be used as fixed size static or or dynamic allocating
factory. The initial size and allocation size is configurable.
Fixed size factories may be used in systems with hard realtime requirements and/or predictable memory usage.
concurrency info:
- all create methods are threadsafe
- factories created with create(...) are not threadsafe
- factories created with createSynchronized(...) are threadsafe
- Author:
- Michael Bien
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intdefault size for internal buffer allocation. -
Method Summary
Modifier and TypeMethodDescriptionstatic CachedBufferFactorycreate()Creates a factory with initial size and allocation size set toDEFAULT_ALLOCATION_SIZE.static CachedBufferFactorycreate(int initialSize) Creates a factory with the specified initial size.static CachedBufferFactorycreate(int initialSize, boolean fixed) Creates a factory with the specified initial size.static CachedBufferFactorycreate(int initialSize, int allocationSize) Creates a factory with the specified initial size and allocation size.static CachedBufferFactorySynchronized version ofcreate().static CachedBufferFactorycreateSynchronized(int initialSize) Synchronized version ofcreate(int).static CachedBufferFactorycreateSynchronized(int initialSize, boolean fixed) Synchronized version ofcreate(int, boolean).static CachedBufferFactorycreateSynchronized(int initialSize, int allocationSize) Synchronized version ofcreate(int, int).voiddestroy()booleanintReturns the allocation size used to create new internal buffers.booleanisFixed()Returns true only if this factory does not allow to allocate more buffers as limited by the initial size.newDirectByteBuffer(byte[] values) newDirectByteBuffer(byte[] values, int offset) newDirectByteBuffer(byte[] values, int offset, int lenght) newDirectByteBuffer(int size) newDirectCharBuffer(char[] values) newDirectCharBuffer(char[] values, int offset) newDirectCharBuffer(char[] values, int offset, int lenght) newDirectCharBuffer(int numElements) newDirectDoubleBuffer(double[] values) newDirectDoubleBuffer(double[] values, int offset) newDirectDoubleBuffer(double[] values, int offset, int lenght) newDirectDoubleBuffer(int numElements) newDirectFloatBuffer(float[] values) newDirectFloatBuffer(float[] values, int offset) newDirectFloatBuffer(float[] values, int offset, int lenght) newDirectFloatBuffer(int numElements) newDirectIntBuffer(int numElements) newDirectIntBuffer(int[] values) newDirectIntBuffer(int[] values, int offset) newDirectIntBuffer(int[] values, int offset, int lenght) newDirectLongBuffer(int numElements) newDirectLongBuffer(long[] values) newDirectLongBuffer(long[] values, int offset) newDirectLongBuffer(long[] values, int offset, int lenght) newDirectShortBuffer(int numElements) newDirectShortBuffer(short[] values) newDirectShortBuffer(short[] values, int offset) newDirectShortBuffer(short[] values, int offset, int lenght) toString()
-
Field Details
-
DEFAULT_ALLOCATION_SIZE
public static final int DEFAULT_ALLOCATION_SIZEdefault size for internal buffer allocation.- See Also:
-
-
Method Details
-
create
Creates a factory with initial size and allocation size set toDEFAULT_ALLOCATION_SIZE. -
create
Creates a factory with the specified initial size. The allocation size is set toDEFAULT_ALLOCATION_SIZE. -
create
Creates a factory with the specified initial size. The allocation size is set toDEFAULT_ALLOCATION_SIZE.- Parameters:
fixed- Creates a fixed size factory which will handle overflows (initial size) with RuntimeExceptions.
-
create
Creates a factory with the specified initial size and allocation size. -
createSynchronized
Synchronized version ofcreate(). -
createSynchronized
Synchronized version ofcreate(int). -
createSynchronized
Synchronized version ofcreate(int, boolean). -
createSynchronized
Synchronized version ofcreate(int, int). -
isFixed
public boolean isFixed()Returns true only if this factory does not allow to allocate more buffers as limited by the initial size. -
getAllocationSize
public int getAllocationSize()Returns the allocation size used to create new internal buffers. 0 means that the buffer will not grows, seeisFixed(). -
destroy
public void destroy() -
newDirectByteBuffer
-
newDirectByteBuffer
-
newDirectByteBuffer
-
newDirectByteBuffer
-
newDirectDoubleBuffer
-
newDirectDoubleBuffer
-
newDirectDoubleBuffer
-
newDirectDoubleBuffer
-
newDirectFloatBuffer
-
newDirectFloatBuffer
-
newDirectFloatBuffer
-
newDirectFloatBuffer
-
newDirectIntBuffer
-
newDirectIntBuffer
-
newDirectIntBuffer
-
newDirectIntBuffer
-
newDirectLongBuffer
-
newDirectLongBuffer
-
newDirectLongBuffer
-
newDirectLongBuffer
-
newDirectShortBuffer
-
newDirectShortBuffer
-
newDirectShortBuffer
-
newDirectShortBuffer
-
newDirectCharBuffer
-
newDirectCharBuffer
-
newDirectCharBuffer
-
newDirectCharBuffer
-
equals
-
toString
-