- java.lang.Object
-
- ch.bind.philib.pool.manager.ByteBufferManager
-
- All Implemented Interfaces:
ObjectManager<ByteBuffer>
public final class ByteBufferManager extends Object implements ObjectManager<ByteBuffer>
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_DIRECT_BUFFER
-
Constructor Summary
Constructors Constructor Description ByteBufferManager(int bufferSize)ByteBufferManager(int bufferSize, boolean directBuffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanReuse(ByteBuffer buf)ByteBuffercreate()booleanprepareForRecycle(ByteBuffer buf)Prepare an object to be reused by a different user.voidrelease(ByteBuffer buf)
-
-
-
Field Detail
-
DEFAULT_DIRECT_BUFFER
public static final boolean DEFAULT_DIRECT_BUFFER
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public ByteBuffer create()
- Specified by:
createin interfaceObjectManager<ByteBuffer>
-
prepareForRecycle
public boolean prepareForRecycle(ByteBuffer buf)
Description copied from interface:ObjectManagerPrepare an object to be reused by a different user. Implementations of this method must make sure that any data from previous users is cleared.- Specified by:
prepareForRecyclein interfaceObjectManager<ByteBuffer>- Parameters:
buf- The object which must be prepared for reuse.- Returns:
trueif this object can be reused,falseotherwise (for example if the size of the offered buffer is too small). After returningfalseObjectManager.release(Object)will be called.
-
release
public void release(ByteBuffer buf)
- Specified by:
releasein interfaceObjectManager<ByteBuffer>
-
canReuse
public boolean canReuse(ByteBuffer buf)
- Specified by:
canReusein interfaceObjectManager<ByteBuffer>- Parameters:
buf- -- Returns:
trueif this pooled object can be reused,falseotherwise. Example: The pooled object is a database connection which might not be reusable because the connection was closed while being in the pool.
-
-