@ManagedObject public class MappedByteBufferPool extends Object
A ByteBuffer pool where ByteBuffers are held in queues that are held in a Map.
Given a capacity factor of 1024, the Map entry with key 1 holds a
queue of ByteBuffers each of capacity 1024, the Map entry with key 2 holds a
queue of ByteBuffers each of capacity 2048, and so on.
| Modifier and Type | Class and Description |
|---|---|
static class |
MappedByteBufferPool.Tagged |
ByteBufferPool.Bucket, ByteBufferPool.Lease| Constructor and Description |
|---|
MappedByteBufferPool()
Creates a new MappedByteBufferPool with a default configuration.
|
MappedByteBufferPool(int factor)
Creates a new MappedByteBufferPool with the given capacity factor.
|
MappedByteBufferPool(int factor,
int maxQueueLength)
Creates a new MappedByteBufferPool with the given configuration.
|
MappedByteBufferPool(int factor,
int maxQueueLength,
Function<Integer,ByteBufferPool.Bucket> newBucket)
Creates a new MappedByteBufferPool with the given configuration.
|
MappedByteBufferPool(int factor,
int maxQueueLength,
Function<Integer,ByteBufferPool.Bucket> newBucket,
long maxHeapMemory,
long maxDirectMemory)
Creates a new MappedByteBufferPool with the given configuration.
|
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
acquire(int size,
boolean direct)
Requests a
ByteBuffer of the given size. |
void |
clear() |
long |
getDirectByteBufferCount() |
long |
getDirectMemory() |
long |
getHeapByteBufferCount() |
long |
getHeapMemory() |
long |
getMemory(boolean direct) |
void |
release(ByteBuffer buffer)
Returns a
ByteBuffer, usually obtained with ByteBufferPool.acquire(int, boolean)
(but not necessarily), making it available for recycling and reuse. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnewByteBufferpublic MappedByteBufferPool()
public MappedByteBufferPool(int factor)
factor - the capacity factorpublic MappedByteBufferPool(int factor,
int maxQueueLength)
factor - the capacity factormaxQueueLength - the maximum ByteBuffer queue lengthpublic MappedByteBufferPool(int factor,
int maxQueueLength,
Function<Integer,ByteBufferPool.Bucket> newBucket)
factor - the capacity factormaxQueueLength - the maximum ByteBuffer queue lengthnewBucket - the function that creates a Bucketpublic MappedByteBufferPool(int factor,
int maxQueueLength,
Function<Integer,ByteBufferPool.Bucket> newBucket,
long maxHeapMemory,
long maxDirectMemory)
factor - the capacity factormaxQueueLength - the maximum ByteBuffer queue lengthnewBucket - the function that creates a BucketmaxHeapMemory - the max heap memory in bytesmaxDirectMemory - the max direct memory in bytespublic ByteBuffer acquire(int size, boolean direct)
ByteBufferPoolRequests a ByteBuffer of the given size.
The returned buffer may have a bigger capacity than the size being requested but it will have the limit set to the given size.
size - the size of the bufferdirect - whether the buffer must be direct or notByteBufferPool.release(ByteBuffer)public void release(ByteBuffer buffer)
ByteBufferPoolReturns a ByteBuffer, usually obtained with ByteBufferPool.acquire(int, boolean)
(but not necessarily), making it available for recycling and reuse.
buffer - the buffer to returnByteBufferPool.acquire(int, boolean)public void clear()
@ManagedAttribute(value="The number of pooled direct ByteBuffers") public long getDirectByteBufferCount()
@ManagedAttribute(value="The number of pooled heap ByteBuffers") public long getHeapByteBufferCount()
@ManagedAttribute(value="The bytes retained by direct ByteBuffers") public long getDirectMemory()
@ManagedAttribute(value="The bytes retained by heap ByteBuffers") public long getHeapMemory()
public long getMemory(boolean direct)
Copyright © 2010 - 2020 Adobe. All Rights Reserved