#include <GstHwImportCache.h>
Classes | |
| struct | Hit |
Public Types | |
| using | DestroyFn = void (*)(Resource&) |
| using | CanDestroyFn = bool (*)(const Resource&) |
| using | EntryId = std::uint64_t |
| Identifies one inserted entry for pin()/unpin(), also after it is parked; never 0. | |
Public Member Functions | |
| GstHwImportCache (DestroyFn destroy, CanDestroyFn destroyableHere=nullptr) | |
| ~GstHwImportCache () | |
| Static teardown: entries still pinned or not destroyable on this thread are leaked, never destroyed unsafely. | |
| GstHwImportCache (const GstHwImportCache &)=delete | |
| GstHwImportCache & | operator= (const GstHwImportCache &)=delete |
| Hit | find (const Key &key) |
| MRU-promoting lookup. The resource pointer is invalidated by the next insert/eraseIf/clear on this cache. | |
| Hit | insert (const Key &key, Resource resource) |
| void | pin (EntryId id) noexcept |
Keeps entry id from being destroyed until a matching unpin(); no-op for an unknown id. | |
| void | unpin (EntryId id) noexcept |
| Releases one pin(). A parked entry is destroyed by the next drainDeferred() once its last pin is gone. | |
| template<class Pred> | |
| void | eraseIf (Pred pred) |
Removes every live entry for which pred(key, resource) holds. | |
| void | clear () |
| void | drainDeferred () |
| Destroys parked entries that are unpinned and destroyable on the calling thread. | |
| std::size_t | size () const noexcept |
| std::size_t | parkedCount () const noexcept |
| Entries removed from the cache but not yet destroyed (pinned, or awaiting their owner thread). | |
Bounded LRU cache for GPU import resources sized for the handful of buffers a decoder pool recycles: a flat array searched linearly, so lookups and inserts never allocate. Serves the AHardwareBuffer path (EGLImages).
Pinned entries (a frame bundle still samples them) are never destroyed: eviction skips them, and erase/clear park them until unpinned. Entries removed where destroyableHere rejects them (e.g. off the render thread that owns the GPU object) are parked as well; drainDeferred() destroys parked entries once both conditions allow it. Not internally synchronized — the caller serializes access.
Definition at line 19 of file GstHwImportCache.h.
| using GstHw::GstHwImportCache< Key, Resource, Capacity >::CanDestroyFn = bool (*)(const Resource&) |
Definition at line 23 of file GstHwImportCache.h.
| using GstHw::GstHwImportCache< Key, Resource, Capacity >::DestroyFn = void (*)(Resource&) |
Definition at line 22 of file GstHwImportCache.h.
| using GstHw::GstHwImportCache< Key, Resource, Capacity >::EntryId = std::uint64_t |
Identifies one inserted entry for pin()/unpin(), also after it is parked; never 0.
Definition at line 25 of file GstHwImportCache.h.
|
inlineexplicit |
Definition at line 35 of file GstHwImportCache.h.
Referenced by GstHwImportCache(), and operator=().
|
inline |
Static teardown: entries still pinned or not destroyable on this thread are leaked, never destroyed unsafely.
Definition at line 41 of file GstHwImportCache.h.
References clear(), and drainDeferred().
|
delete |
References GstHwImportCache().
|
inline |
Definition at line 125 of file GstHwImportCache.h.
References eraseIf().
Referenced by ~GstHwImportCache().
|
inline |
Destroys parked entries that are unpinned and destroyable on the calling thread.
Definition at line 131 of file GstHwImportCache.h.
Referenced by ~GstHwImportCache().
|
inline |
Removes every live entry for which pred(key, resource) holds.
Definition at line 116 of file GstHwImportCache.h.
Referenced by clear().
|
inline |
MRU-promoting lookup. The resource pointer is invalidated by the next insert/eraseIf/clear on this cache.
Definition at line 51 of file GstHwImportCache.h.
|
inline |
Stores resource under key, replacing any entry for it and evicting the least recently used unpinned entry when full. Fails, retiring resource, when every slot is pinned.
Definition at line 64 of file GstHwImportCache.h.
|
delete |
References GstHwImportCache().
|
inlinenoexcept |
Entries removed from the cache but not yet destroyed (pinned, or awaiting their owner thread).
Definition at line 153 of file GstHwImportCache.h.
|
inlinenoexcept |
Keeps entry id from being destroyed until a matching unpin(); no-op for an unknown id.
Definition at line 99 of file GstHwImportCache.h.
|
inlinenoexcept |
Definition at line 143 of file GstHwImportCache.h.
|
inlinenoexcept |
Releases one pin(). A parked entry is destroyed by the next drainDeferred() once its last pin is gone.
Definition at line 107 of file GstHwImportCache.h.