public interface ILspGLResourceCache extends ILcdMultiKeyMap<Object,ALspGLResource>
Storing a new entry in the cache can result in the removal and destruction of one
or more existing entries due to size limitations (getMaxBytes()
).
Bound ALspGLResource
are never removed. Since using the cache can
result in a call to destroy
,
this cache can only be accessed from the painting thread.
ILcdMultiKeyMap
that
allows storage and retrieval of OpenGL resource objects by a sequence of keys.
This facilitates removal of multiple resources at once by removing an entire
branch of the cache tree for example. See ILcdMultiKeyMap
for a detailed description
of the workings of a multi-key map.
The resource cache is not thread-safe and should only be accessed from
the painting thread.TLspViewServices.getGLResourceCache()
,
ALspGLResource
Modifier and Type | Method and Description |
---|---|
void |
addCacheListener(ILspGLResourceCacheListener aListener)
Adds the given listener so that it gets notified of key resource events
(addition, usage, removal).
|
Set<? extends Map.Entry<Object,? extends ILspGLResourceCache>> |
branchEntrySet()
Gets the entries of this branch's branch map.
|
Collection<? extends ILspGLResourceCache> |
branchValues()
Gets the values of this branch's leaf map.
|
void |
destroy(ILcdGLDrawable aGLDrawable)
Frees all resources stored in the cache.
|
ILspGLResourceCache |
getBranch(Object[] aKeys)
Returns the branch that is associated with the given key, or
null
if the branch does not exist. |
long |
getBytes()
Gets the sum of the total number of bytes allocated by
the resources stored in the cache.
|
long |
getBytes(String aSourceString)
Gets the sum of the total number of bytes allocated by
the resources stored in the cache
for the given identifier.
|
long |
getMaxBytes()
Gets the maximal number of bytes that can be stored
in this cache.
|
ILspGLResourceCache |
getOrCreateBranch(Object[] aKeys)
Creates and returns a new branch for the given key.
|
int |
getResourceCount()
Gets the number of resources stored in the cache.
|
Collection<String> |
getSourceStringsInDecreasingOrder()
Gets the resources' source strings sorted in decreasing
bytes usage orders.
|
void |
removeCacheListener(ILspGLResourceCacheListener aListener)
Removes the given listener so that it stops being notified of resource
events.
|
branchKeySet, branchSize, clearRecursive, get, put, recursiveLeafKeySet, remove, removeRecursive
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
void destroy(ILcdGLDrawable aGLDrawable)
aGLDrawable
- drawableint getResourceCount()
long getBytes()
long getBytes(String aSourceString)
aSourceString
- the identifier for which
the memory usage is queriedlong getMaxBytes()
Collection<String> getSourceStringsInDecreasingOrder()
void addCacheListener(ILspGLResourceCacheListener aListener)
It is highly discouraged to add listeners to the GL resource cache
for production purposes since this may result in the generation of
a large amount of TLspGLResourceCacheEvent
objects.
However, it can be useful during monitoring or debugging.
aListener
- the listenervoid removeCacheListener(ILspGLResourceCacheListener aListener)
aListener
- the listener to remove.ILspGLResourceCache getBranch(Object[] aKeys)
ILcdMultiKeyMap
null
if the branch does not exist.getBranch
in interface ILcdMultiKeyMap<Object,ALspGLResource>
aKeys
- the keynull
if
a branch does not exist.ILcdMultiKeyMap.getOrCreateBranch(Object[])
ILspGLResourceCache getOrCreateBranch(Object[] aKeys)
ILcdMultiKeyMap
getOrCreateBranch
in interface ILcdMultiKeyMap<Object,ALspGLResource>
aKeys
- the keynull
.Set<? extends Map.Entry<Object,? extends ILspGLResourceCache>> branchEntrySet()
ILcdMultiKeyMap
branchEntrySet
in interface ILcdMultiKeyMap<Object,ALspGLResource>
Collection<? extends ILspGLResourceCache> branchValues()
ILcdMultiKeyMap
branchValues
in interface ILcdMultiKeyMap<Object,ALspGLResource>