| 58 | }; |
| 59 | |
| 60 | struct ObjectCacheDestructorData { |
| 61 | ObjectCacheDestructorData(ObjectCacheDestructorContext ctx, |
| 62 | uintptr_t ptr, |
| 63 | const KAllocation::Key& k, |
| 64 | uint32_t expiryTime, |
| 65 | uint32_t creationTime, |
| 66 | uint32_t lastAccessTime) |
| 67 | : context(ctx), |
| 68 | objectPtr(ptr), |
| 69 | key(k), |
| 70 | expiryTime(expiryTime), |
| 71 | creationTime(creationTime), |
| 72 | lastAccessTime(lastAccessTime) {} |
| 73 | |
| 74 | // release the evicted/removed/expired object memory |
| 75 | template <typename T> |
| 76 | void deleteObject() { |
| 77 | delete reinterpret_cast<T*>(objectPtr); |
| 78 | } |
| 79 | |
| 80 | // remove or eviction |
| 81 | ObjectCacheDestructorContext context; |
| 82 | |
| 83 | // pointer of the evicted/removed/expired object |
| 84 | uintptr_t objectPtr; |
| 85 | |
| 86 | // the key corresponding to the evicted/removed/expired object |
| 87 | const KAllocation::Key& key; |
| 88 | |
| 89 | // the expiry time of the object |
| 90 | uint32_t expiryTime; |
| 91 | |
| 92 | // the creation time of the object |
| 93 | uint32_t creationTime; |
| 94 | |
| 95 | // the last time this object was accessed |
| 96 | uint32_t lastAccessTime; |
| 97 | }; |
| 98 | |
| 99 | template <typename AllocatorT> |
| 100 | class ObjectCache : public ObjectCacheBase<AllocatorT> { |