public final class DiscardBufferPool extends Object implements BufferProvider, BufferRecycler
BufferProvider.BufferAvailabilityRegistration| Constructor and Description |
|---|
DiscardBufferPool() |
| Modifier and Type | Method and Description |
|---|---|
int |
getBufferSize()
Returns the size of buffers (in bytes) available at this buffer provider.
|
void |
recycle(MemorySegment buffer)
Called by
Buffer to return a MemorySegment to its original buffer pool. |
BufferProvider.BufferAvailabilityRegistration |
registerBufferAvailabilityListener(BufferAvailabilityListener listener)
Registers the given
BufferAvailabilityListener with an empty buffer pool. |
void |
reportAsynchronousEvent()
Reports an asynchronous event and interrupts each blocking method of this buffer provider in order to allow the
blocked thread to respond to the event.
|
Buffer |
requestBuffer(int minBufferSize)
Requests a buffer with a minimum size of
minBufferSize. |
Buffer |
requestBufferBlocking(int minBufferSize)
Requests a buffer with a minimum size of
minBufferSize. |
public Buffer requestBuffer(int minBufferSize)
BufferProviderminBufferSize. The method returns immediately, even if the
request could not be fulfilled.requestBuffer in interface BufferProviderminBufferSize - minimum size of the requested buffer (in bytes)null if no such buffer is currently availablepublic Buffer requestBufferBlocking(int minBufferSize)
BufferProviderminBufferSize. The method blocks until the request has
been fulfilled or BufferProvider.reportAsynchronousEvent() has been called.requestBufferBlocking in interface BufferProviderminBufferSize - minimum size of the requested buffer (in bytes)public int getBufferSize()
BufferProvidergetBufferSize in interface BufferProviderpublic void reportAsynchronousEvent()
BufferProviderreportAsynchronousEvent in interface BufferProviderpublic BufferProvider.BufferAvailabilityRegistration registerBufferAvailabilityListener(BufferAvailabilityListener listener)
BufferProviderBufferAvailabilityListener with an empty buffer pool.
The registration only succeeds, if the buffer pool is empty and has not been destroyed yet.
The registered listener will receive a notification when at least one buffer has become available again. After the notification, the listener will be unregistered.
registerBufferAvailabilityListener in interface BufferProviderlistener - the listener to be registeredtrue if the registration has been successful; false if the registration
failed, because the buffer pool was not empty or has already been destroyedpublic void recycle(MemorySegment buffer)
BufferRecyclerBuffer to return a MemorySegment to its original buffer pool.recycle in interface BufferRecyclerbuffer - the segment to be recycledCopyright © 2014 The Apache Software Foundation. All rights reserved.