/** * Makes the given buffer available for further calls to {@link #getByteArray(int)} with the same buffer length. * Returns <code>true</code> if the buffer was added to the pool, <code>false</code> if the buffer was already in * the pool. * * <p>After calling this method, the given buffer instance <b>must not be used</b>, otherwise it could get * corrupted if other threads were using it.</p> * * @param buffer the buffer instance to make available for further use * @return <code>true</code> if the buffer was added to the pool, <code>false</code> if the buffer was already in the pool * @throws IllegalArgumentException if specified buffer is null */ public static synchronized boolean releaseByteArray(byte buffer[]) { return releaseBuffer(buffer, new ByteArrayFactory()); }
/** * Makes the given buffer available for further calls to {@link #getCharArray(int)} with the same buffer length. * Returns <code>true</code> if the buffer was added to the pool, <code>false</code> if the buffer was already in * the pool. * * <p>After calling this method, the given buffer instance <b>must not be used</b>, otherwise it could get * corrupted if other threads were using it.</p> * * @param buffer the buffer instance to make available for further use * @return <code>true</code> if the buffer was added to the pool, <code>false</code> if the buffer was already in the pool * @throws IllegalArgumentException if specified buffer is null */ public static synchronized boolean releaseCharArray(char buffer[]) { return releaseBuffer(buffer, new CharArrayFactory()); }
/** * Makes the given buffer available for further calls to {@link #getByteBuffer(int)} with the same buffer capacity. * Returns <code>true</code> if the buffer was added to the pool, <code>false</code> if the buffer was already in * the pool. * * <p>After calling this method, the given buffer instance <b>must not be used</b>, otherwise it could get * corrupted if other threads were using it.</p> * * @param buffer the buffer instance to make available for further use * @return <code>true</code> if the buffer was added to the pool, <code>false</code> if the buffer was already in the pool * @throws IllegalArgumentException if specified buffer is null */ public static synchronized boolean releaseByteBuffer(ByteBuffer buffer) { return releaseBuffer(buffer, new ByteBufferFactory()); }
/** * Makes the given buffer available for further calls to {@link #getCharBuffer(int)} with the same buffer capacity. * Returns <code>true</code> if the buffer was added to the pool, <code>false</code> if the buffer was already in * the pool. * * <p>After calling this method, the given buffer instance <b>must not be used</b>, otherwise it could get * corrupted if other threads were using it.</p> * * @param buffer the buffer instance to make available for further use * @return <code>true</code> if the buffer was added to the pool, <code>false</code> if the buffer was already in the pool * @throws IllegalArgumentException if specified buffer is null */ public static synchronized boolean releaseCharBuffer(CharBuffer buffer) { return releaseBuffer(buffer, new CharBufferFactory()); }
BufferPool.releaseBuffer(buffer3, factory); assertBufferCount(originalBufferCount+1, factory); assert BufferPool.containsBuffer(buffer3, factory); for(int b=0; b<buffers.length; b++) { assert BufferPool.releaseBuffer(buffers[b], factory); assert BufferPool.containsBuffer(buffers[b], factory); assertBufferCount(originalBufferCount+(b+1), factory); assert !BufferPool.releaseBuffer(buffers[b], factory); assert BufferPool.containsBuffer(buffers[b], factory); assertBufferCount(originalBufferCount+(b+1), factory); long newPoolSize; for(int i=0; i<nbBuffers; i++) { assert BufferPool.releaseBuffer(buffers[i], factory); newPoolSize = BufferPool.getPoolSize(); assert lastPoolSize+bufferSize == newPoolSize; assert !BufferPool.releaseBuffer(extraBuffer, factory);