public class ByteBufferResourcePool extends ResourcePool<ByteBuffer>
mCurrentCapacity, mMaxCapacity, mResources
Constructor and Description |
---|
ByteBufferResourcePool(int maxCapacity,
int bufferSize)
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the resource pool.
|
ByteBuffer |
createNewResource()
Creates a new resource which will be added to the resource pool after the user is done using
it.
|
void |
release(ByteBuffer resource)
Releases an object of type T, this must be called after the thread is done using a resource
obtained by acquire.
|
acquire, acquire, size
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
acquireCloseable, acquireCloseable
public ByteBufferResourcePool(int maxCapacity, int bufferSize)
maxCapacity
- the max capacitybufferSize
- the buffer sizepublic void close() throws IOException
ResourcePool
close
in interface Closeable
close
in interface AutoCloseable
close
in class ResourcePool<ByteBuffer>
IOException
public void release(ByteBuffer resource)
ResourcePool
release
in interface Pool<ByteBuffer>
release
in class ResourcePool<ByteBuffer>
resource
- the resource to be released, it should not be reused after calling this methodpublic ByteBuffer createNewResource()
ResourcePool
createNewResource
in class ResourcePool<ByteBuffer>
Copyright © 2023. All Rights Reserved.