Package org.restheart.buffers
Class ThreadAwareByteBufferPool
java.lang.Object
org.restheart.buffers.ThreadAwareByteBufferPool
- All Implemented Interfaces:
io.undertow.connector.ByteBufferPool,Closeable,AutoCloseable
public class ThreadAwareByteBufferPool
extends Object
implements io.undertow.connector.ByteBufferPool
A byte buffer pool that delegates to specific implementations based on the thread type.
For IO threads, it utilizes the undertow.DefaultByteBufferPool to pool resources efficiently.
For virtual worker threads, it uses the NotPoolingByteBufferPool, which doesn't pool resources, to optimize performance
given the unique characteristics of virtual threads.
- Author:
- Andrea Di Cesare
-
Constructor Summary
ConstructorsConstructorDescriptionThreadAwareByteBufferPool(boolean direct, int bufferSize, boolean enablePooling) -
Method Summary
-
Constructor Details
-
ThreadAwareByteBufferPool
public ThreadAwareByteBufferPool(boolean direct, int bufferSize, boolean enablePooling) - Parameters:
direct- If io threads implementation should use direct buffersbufferSize- The buffer size to useenablePooling- true to enable pooling for platform threads
-
-
Method Details
-
getBufferSize
public int getBufferSize()- Specified by:
getBufferSizein interfaceio.undertow.connector.ByteBufferPool
-
isDirect
public boolean isDirect()- Specified by:
isDirectin interfaceio.undertow.connector.ByteBufferPool
-
allocate
public io.undertow.connector.PooledByteBuffer allocate()- Specified by:
allocatein interfaceio.undertow.connector.ByteBufferPool
-
getArrayBackedPool
public io.undertow.connector.ByteBufferPool getArrayBackedPool()- Specified by:
getArrayBackedPoolin interfaceio.undertow.connector.ByteBufferPool
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceio.undertow.connector.ByteBufferPool- Specified by:
closein interfaceCloseable
-