Package com.automation_pros.odva.util
Class BytesSoftCache
- java.lang.Object
-
- com.automation_pros.odva.util.SizedSoftCache<byte[]>
-
- com.automation_pros.odva.util.BytesSoftCache
-
public class BytesSoftCache extends SizedSoftCache<byte[]>
-
-
Field Summary
-
Fields inherited from class com.automation_pros.odva.util.SizedSoftCache
FullName, identity, minimum, sizedCaches, sLogger, traceIndex
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]create(int size)When the cache runs empty, further allocations must create new objects.protected intdynamicEach(int size)Implementations must provide a function that estimates the GC impact of an instance of a given size.static byte[]get(int size)Obtain a byte array that is at least the given size.protected booleanqualified(byte[] recycled)An item returned from a user might have been changed in a way that makes it unsuitable for reuse.static voidrelease(byte[] recycle)protected intsizeOf(byte[] recycle)When an object is freed for recycling, its size must be examined to determine the appropriate nested cache to use, and whether it exactly matches that cache.-
Methods inherited from class com.automation_pros.odva.util.SizedSoftCache
allocate, free, normalizedSize
-
-
-
-
Method Detail
-
get
public static byte[] get(int size)
Obtain a byte array that is at least the given size. It will be recycled back into this cache by the garbage collector if memory pressure permits.- Parameters:
size-- Returns:
-
release
public static void release(byte[] recycle)
-
dynamicEach
protected int dynamicEach(int size)
Description copied from class:SizedSoftCacheImplementations must provide a function that estimates the GC impact of an instance of a given size.- Specified by:
dynamicEachin classSizedSoftCache<byte[]>- Returns:
-
sizeOf
protected int sizeOf(byte[] recycle)
Description copied from class:SizedSoftCacheWhen an object is freed for recycling, its size must be examined to determine the appropriate nested cache to use, and whether it exactly matches that cache.- Specified by:
sizeOfin classSizedSoftCache<byte[]>- Returns:
- The actual size of the object to recycle.
-
qualified
protected boolean qualified(byte[] recycled)
Description copied from class:SizedSoftCacheAn item returned from a user might have been changed in a way that makes it unsuitable for reuse. This method gives the implementation a chance to verify that and/or make corrections.- Specified by:
qualifiedin classSizedSoftCache<byte[]>- Parameters:
recycled- The subject item that is to be placed back in this cache's fast access list.- Returns:
- True if ready for re-use, false if to be discarded.
-
create
protected byte[] create(int size)
Description copied from class:SizedSoftCacheWhen the cache runs empty, further allocations must create new objects. Since the queue is based on soft references, the garbage collector can throw some away at will.- Specified by:
createin classSizedSoftCache<byte[]>- Returns:
-
-