|
|
@ -474,11 +474,14 @@ LRUCache::LRUCache(size_t capacity, int num_shard_bits, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LRUCache::~LRUCache() { |
|
|
|
LRUCache::~LRUCache() { |
|
|
|
|
|
|
|
if (shards_ != nullptr) { |
|
|
|
|
|
|
|
assert(num_shards_ > 0); |
|
|
|
for (int i = 0; i < num_shards_; i++) { |
|
|
|
for (int i = 0; i < num_shards_; i++) { |
|
|
|
shards_[i].~LRUCacheShard(); |
|
|
|
shards_[i].~LRUCacheShard(); |
|
|
|
} |
|
|
|
} |
|
|
|
port::cacheline_aligned_free(shards_); |
|
|
|
port::cacheline_aligned_free(shards_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CacheShard* LRUCache::GetShard(int shard) { |
|
|
|
CacheShard* LRUCache::GetShard(int shard) { |
|
|
|
return reinterpret_cast<CacheShard*>(&shards_[shard]); |
|
|
|
return reinterpret_cast<CacheShard*>(&shards_[shard]); |
|
|
@ -504,6 +507,7 @@ void LRUCache::DisownData() { |
|
|
|
// Do not drop data if compile with ASAN to suppress leak warning.
|
|
|
|
// Do not drop data if compile with ASAN to suppress leak warning.
|
|
|
|
#ifndef __SANITIZE_ADDRESS__ |
|
|
|
#ifndef __SANITIZE_ADDRESS__ |
|
|
|
shards_ = nullptr; |
|
|
|
shards_ = nullptr; |
|
|
|
|
|
|
|
num_shards_ = 0; |
|
|
|
#endif // !__SANITIZE_ADDRESS__
|
|
|
|
#endif // !__SANITIZE_ADDRESS__
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|