public class PhantomReferenceLimitedPageSource extends Object implements PageSource
PhantomReference based limited byte buffer source.
This buffer source tracks 'freeing' of allocated byte buffers using phantom
references to the allocated buffers and an associated reference queue. An
AtomicLong is then used to track number of available bytes for
allocation.
| Constructor and Description |
|---|
PhantomReferenceLimitedPageSource(long max)
Create a source that will allocate at most
max bytes. |
| Modifier and Type | Method and Description |
|---|---|
Page |
allocate(int size,
boolean thief,
boolean victim,
OffHeapStorageArea owner)
Allocates a byte buffer of the given size.
|
void |
free(Page buffer)
Frees the supplied buffer.
|
String |
toString() |
public PhantomReferenceLimitedPageSource(long max)
max bytes.max - the maximum total size of all available bufferspublic Page allocate(int size, boolean thief, boolean victim, OffHeapStorageArea owner)
This BufferSource places no restrictions on the requested size of
the buffer.
allocate in interface PageSourcesize - size of page to allocatethief - true if the allocation can steal space from victimsvictim - true if the allocated page should be eligible for stealingowner - owner from which subsequent steal should occurnull in the case of failurepublic void free(Page buffer)
This implementation is a no-op, no validation of the supplied buffer is attempted, as freeing of allocated buffers is monitored via phantom references.
free in interface PageSourceCopyright © 2015–2024. All rights reserved.