public abstract class ByteBufferPool extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ByteBufferPool.Set
A set of buffer pools for each size, which can either be
ByteBufferPool.Set.DIRECT or ByteBufferPool.Set.HEAP . |
Modifier and Type | Field and Description |
---|---|
static ByteBufferPool |
LARGE_DIRECT
The large direct buffer pool.
|
static ByteBufferPool |
LARGE_HEAP
The large heap buffer pool.
|
static int |
LARGE_SIZE
The size of large buffers.
|
static ByteBufferPool |
MEDIUM_DIRECT
The medium direct buffer pool.
|
static ByteBufferPool |
MEDIUM_HEAP
The medium heap buffer pool.
|
static int |
MEDIUM_SIZE
The size of medium buffers.
|
static ByteBufferPool |
SMALL_DIRECT
The small direct buffer pool.
|
static ByteBufferPool |
SMALL_HEAP
The small heap buffer pool.
|
static int |
SMALL_SIZE
The size of small buffers.
|
Modifier and Type | Method and Description |
---|---|
<T,U,E extends Exception> |
acceptWithCacheEx(int cacheSize,
org.wildfly.common.function.ExceptionBiConsumer<T,U,E> consumer,
T param1,
U param2)
Perform the given operation with the addition of a buffer cache of the given size.
|
<T,E extends Exception> |
acceptWithCacheEx(int cacheSize,
org.wildfly.common.function.ExceptionConsumer<T,E> consumer,
T param)
Perform the given operation with the addition of a buffer cache of the given size.
|
ByteBuffer |
allocate()
Allocate a buffer from this source pool.
|
void |
allocate(ByteBuffer[] array,
int offs)
Bulk-allocate buffers from this pool.
|
void |
allocate(ByteBuffer[] array,
int offs,
int len)
Bulk-allocate buffers from this pool.
|
<T,U,R,E extends Exception> |
applyWithCacheEx(int cacheSize,
org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> function,
T param1,
U param2)
Perform the given operation with the addition of a buffer cache of the given size.
|
<T,R,E extends Exception> |
applyWithCacheEx(int cacheSize,
org.wildfly.common.function.ExceptionFunction<T,R,E> function,
T param)
Perform the given operation with the addition of a buffer cache of the given size.
|
static void |
flushAllCaches()
Flush all thread-local caches for all buffer sizes.
|
void |
flushCaches()
Flush thread-local caches.
|
static void |
free(ByteBuffer buffer)
Free a buffer into its appropriate pool based on its size.
|
static void |
free(ByteBuffer[] array,
int offs,
int len)
Bulk-free buffers from an array as with
free(ByteBuffer) . |
int |
getSize()
Get the size of buffers returned by this source.
|
<R,E extends Exception> |
getWithCacheEx(int cacheSize,
org.wildfly.common.function.ExceptionSupplier<R,E> supplier)
Perform the given operation with the addition of a buffer cache of the given size.
|
boolean |
isDirect()
Determine if this source returns direct buffers.
|
void |
runWithCache(int cacheSize,
Runnable runnable)
Perform the given operation with the addition of a buffer cache of the given size.
|
<E extends Exception> |
runWithCacheEx(int cacheSize,
org.wildfly.common.function.ExceptionRunnable<E> runnable)
Perform the given operation with the addition of a buffer cache of the given size.
|
static void |
zeroAndFree(ByteBuffer buffer)
Free a buffer as with
free(ByteBuffer) except the buffer is first zeroed and cleared. |
public static final int LARGE_SIZE
public static final int MEDIUM_SIZE
public static final int SMALL_SIZE
public static final ByteBufferPool LARGE_DIRECT
LARGE_SIZE
.public static final ByteBufferPool MEDIUM_DIRECT
MEDIUM_SIZE
.public static final ByteBufferPool SMALL_DIRECT
SMALL_SIZE
.public static final ByteBufferPool LARGE_HEAP
LARGE_SIZE
.public static final ByteBufferPool MEDIUM_HEAP
MEDIUM_SIZE
.public static final ByteBufferPool SMALL_HEAP
SMALL_SIZE
.public ByteBuffer allocate()
free(ByteBuffer)
method.public void allocate(ByteBuffer[] array, int offs)
free(ByteBuffer)
method.array
- the array of buffers to filloffs
- the offset into the array to fillpublic void allocate(ByteBuffer[] array, int offs, int len)
free(ByteBuffer)
method.array
- the array of buffers to filloffs
- the offset into the array to filllen
- the number of buffers to fill in the arraypublic static void free(ByteBuffer buffer)
buffer
- the buffer to freepublic static void free(ByteBuffer[] array, int offs, int len)
free(ByteBuffer)
. The freed entries will be assigned to
null
.array
- the buffer arrayoffs
- the offset into the arraylen
- the number of buffers to freepublic static void zeroAndFree(ByteBuffer buffer)
free(ByteBuffer)
except the buffer is first zeroed and cleared.buffer
- the buffer to freepublic boolean isDirect()
true
if the buffers are direct, false
if they are heappublic int getSize()
public void flushCaches()
public static void flushAllCaches()
public <T,U,E extends Exception> void acceptWithCacheEx(int cacheSize, org.wildfly.common.function.ExceptionBiConsumer<T,U,E> consumer, T param1, U param2) throws E extends Exception
T
- the type of the first parameterU
- the type of the second parameterE
- the exception type thrown by the operationcacheSize
- the cache size to run underconsumer
- the action to runparam1
- the first parameter to pass to the actionparam2
- the second parameter to pass to the actionE
- if the nested action threw an exceptionE extends Exception
public <T,E extends Exception> void acceptWithCacheEx(int cacheSize, org.wildfly.common.function.ExceptionConsumer<T,E> consumer, T param) throws E extends Exception
T
- the type of the parameterE
- the exception type thrown by the operationcacheSize
- the cache size to run underconsumer
- the action to runparam
- the parameter to pass to the actionE
- if the nested action threw an exceptionE extends Exception
public <E extends Exception> void runWithCacheEx(int cacheSize, org.wildfly.common.function.ExceptionRunnable<E> runnable) throws E extends Exception
E
- the exception type thrown by the operationcacheSize
- the cache size to run underrunnable
- the action to runE
- if the nested action threw an exceptionE extends Exception
public void runWithCache(int cacheSize, Runnable runnable)
cacheSize
- the cache size to run underrunnable
- the action to runpublic <T,U,R,E extends Exception> R applyWithCacheEx(int cacheSize, org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> function, T param1, U param2) throws E extends Exception
T
- the type of the first parameterU
- the type of the second parameterR
- the return type of the operationE
- the exception type thrown by the operationcacheSize
- the cache size to run underfunction
- the action to runparam1
- the first parameter to pass to the actionparam2
- the second parameter to pass to the actionE
- if the nested action threw an exceptionE extends Exception
public <T,R,E extends Exception> R applyWithCacheEx(int cacheSize, org.wildfly.common.function.ExceptionFunction<T,R,E> function, T param) throws E extends Exception
T
- the type of the parameterR
- the return type of the operationE
- the exception type thrown by the operationcacheSize
- the cache size to run underfunction
- the action to runparam
- the parameter to pass to the actionE
- if the nested action threw an exceptionE extends Exception
public <R,E extends Exception> R getWithCacheEx(int cacheSize, org.wildfly.common.function.ExceptionSupplier<R,E> supplier) throws E extends Exception
R
- the return type of the operationE
- the exception type thrown by the operationcacheSize
- the cache size to run undersupplier
- the action to runE
- if the nested action threw an exceptionE extends Exception
Copyright © 2019 JBoss by Red Hat. All rights reserved.