public interface AllocationListener
It might be called from multiple threads if the allocator hierarchy shares a listener, in which case, the provider should take care of making the implementation thread-safe.
Modifier and Type | Field and Description |
---|---|
static AllocationListener |
NOOP |
Modifier and Type | Method and Description |
---|---|
default void |
onAllocation(long size)
Called each time a new buffer has been allocated.
|
default void |
onChildAdded(BufferAllocator parentAllocator,
BufferAllocator childAllocator)
Called immediately after a child allocator was added to the parent allocator.
|
default void |
onChildRemoved(BufferAllocator parentAllocator,
BufferAllocator childAllocator)
Called immediately after a child allocator was removed from the parent allocator.
|
default boolean |
onFailedAllocation(long size,
AllocationOutcome outcome)
Called whenever an allocation failed, giving the caller a chance to create some space in the
allocator (either by freeing some resource, or by changing the limit), and, if successful,
allowing the allocator to retry the allocation.
|
default void |
onPreAllocation(long size)
Called each time a new buffer has been requested.
|
default void |
onRelease(long size)
Informed each time a buffer is released from allocation.
|
static final AllocationListener NOOP
default void onPreAllocation(long size)
An exception can be safely thrown by this method to terminate the allocation.
size
- the buffer size being allocateddefault void onAllocation(long size)
An exception cannot be thrown by this method.
size
- the buffer size being allocateddefault void onRelease(long size)
An exception cannot be thrown by this method.
size
- The size of the buffer being released.default boolean onFailedAllocation(long size, AllocationOutcome outcome)
size
- the buffer size that was being allocatedoutcome
- the outcome of the failed allocation. Carries information of what faileddefault void onChildAdded(BufferAllocator parentAllocator, BufferAllocator childAllocator)
parentAllocator
- The parent allocator to which a child was addedchildAllocator
- The child allocator that was just addeddefault void onChildRemoved(BufferAllocator parentAllocator, BufferAllocator childAllocator)
parentAllocator
- The parent allocator from which a child was removedchildAllocator
- The child allocator that was just removedCopyright © 2023 The Apache Software Foundation. All rights reserved.