| 153 | } |
| 154 | |
| 155 | void PoolAllocator::Clear() { |
| 156 | if (has_size_limit_) { |
| 157 | mutex_lock lock(mutex_); |
| 158 | for (auto iter : pool_) { |
| 159 | PtrRecord* pr = iter.second; |
| 160 | allocator_->Free(pr->ptr, pr->num_bytes); |
| 161 | delete pr; |
| 162 | } |
| 163 | pool_.clear(); |
| 164 | get_from_pool_count_ = 0; |
| 165 | put_count_ = 0; |
| 166 | allocated_count_ = 0; |
| 167 | evicted_count_ = 0; |
| 168 | lru_head_ = nullptr; |
| 169 | lru_tail_ = nullptr; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | void PoolAllocator::RemoveFromList(PtrRecord* pr) { |
| 174 | if (pr->prev == nullptr) { |