com.firefly.net.buffer.ThreadSafeIOBufferPool Maven / Gradle / Ivy
package com.firefly.net.buffer;
import java.nio.ByteBuffer;
import com.firefly.net.ReceiveBufferPool;
public class ThreadSafeIOBufferPool implements ReceiveBufferPool {
private final ThreadLocal receiveBufferPool = new ThreadLocal(){
@Override
protected ReceiveBufferPool initialValue() {
return new IOBufferPool();
}
};
@Override
public final ByteBuffer acquire(int size) {
return receiveBufferPool.get().acquire(size);
}
@Override
public final void release(ByteBuffer buffer) {
receiveBufferPool.get().release(buffer);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy