Make callback outlive LruCache.

The callback can be called by the destructor of LruCache, so it needs to be destructed last.

Bug: 227635615
Change-Id: I7d965a2000c1ec32d9c9e88d25ab0c1ba3e9c739
This commit is contained in:
Florian Mayer 2022-03-31 20:21:12 +00:00
parent 48d403a511
commit e0240d3f61
1 changed files with 3 additions and 3 deletions

View File

@ -298,8 +298,8 @@ TEST_F(LruCacheTest, ClearReuseOk) {
}
TEST_F(LruCacheTest, Callback) {
LruCache<SimpleKey, StringValue> cache(100);
EntryRemovedCallback callback;
LruCache<SimpleKey, StringValue> cache(100);
cache.setOnEntryRemovedListener(&callback);
cache.put(1, "one");
@ -313,8 +313,8 @@ TEST_F(LruCacheTest, Callback) {
}
TEST_F(LruCacheTest, CallbackOnClear) {
LruCache<SimpleKey, StringValue> cache(100);
EntryRemovedCallback callback;
LruCache<SimpleKey, StringValue> cache(100);
cache.setOnEntryRemovedListener(&callback);
cache.put(1, "one");
@ -326,8 +326,8 @@ TEST_F(LruCacheTest, CallbackOnClear) {
}
TEST_F(LruCacheTest, CallbackRemovesKeyWorksOK) {
LruCache<KeyWithPointer, StringValue> cache(1);
InvalidateKeyCallback callback;
LruCache<KeyWithPointer, StringValue> cache(1);
cache.setOnEntryRemovedListener(&callback);
KeyWithPointer key1;
key1.ptr = new int(1);