org.xerial.snappy.pool.QuiescentBufferPool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisson-all Show documentation
Show all versions of redisson-all Show documentation
Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava3/Reactive API. Client side caching. Over 50 Redis based Java objects and services: JCache API, Apache Tomcat, Hibernate, Spring, Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Scheduler, RPC
package org.xerial.snappy.pool;
import java.nio.ByteBuffer;
/**
* A {@link BufferPool} implementation which does no pooling. New instances will be created for each call to allocate.
* @author Brett Okken
*/
public final class QuiescentBufferPool implements BufferPool {
private static final QuiescentBufferPool INSTANCE = new QuiescentBufferPool();
private QuiescentBufferPool() {
}
/**
* @return Instance of {@link BufferPool} which does no caching/reuse of instances.
*/
public static BufferPool getInstance() {
return INSTANCE;
}
/**
* Creates a new {@code byte[]} of size.
*/
@Override
public byte[] allocateArray(int size) {
return new byte[size];
}
/**
* Does nothing.
*/
@Override
public void releaseArray(byte[] buffer) {
}
/**
* {@link ByteBuffer#allocateDirect(int) Allocates} a direct {@link ByteBuffer} of size.
*/
@Override
public ByteBuffer allocateDirect(int size) {
return ByteBuffer.allocateDirect(size);
}
/**
* Aggressively releases native resources associated with buffer.
*/
@Override
public void releaseDirect(ByteBuffer buffer) {
assert buffer != null && buffer.isDirect();
DirectByteBuffers.releaseDirectByteBuffer(buffer);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy