| 1091 | } |
| 1092 | |
| 1093 | void LIRSCacheShard::CleanupThreadState(LIRSThreadState* tstate) { |
| 1094 | // evict things that need to be evicted |
| 1095 | for (LIRSHandle* e : tstate->handles_to_evict) { |
| 1096 | DCHECK_EQ(e->residency(), EVICTING); |
| 1097 | DCHECK_EQ(e->num_references(), 0); |
| 1098 | if (e->eviction_callback_) { |
| 1099 | e->eviction_callback_->EvictedEntry(e->key(), e->value()); |
| 1100 | } |
| 1101 | UpdateMemTracker(-static_cast<int64_t>(e->charge())); |
| 1102 | // The eviction is done, set the residency back to NOT_RESIDENT |
| 1103 | auto state_transition = e->modify_atomic_state([] (AtomicState& cur_state) { |
| 1104 | DCHECK_EQ(cur_state.residency, EVICTING); |
| 1105 | DCHECK_EQ(cur_state.ref_count, 0); |
| 1106 | cur_state.residency = NOT_RESIDENT; |
| 1107 | }); |
| 1108 | // If the handle transitioned to UNINITIALIZED before we set it to NOT_RESIDENT, |
| 1109 | // then we are responsible for freeing it. |
| 1110 | if (state_transition.before.state == UNINITIALIZED) { |
| 1111 | Free(e); |
| 1112 | } |
| 1113 | } |
| 1114 | tstate->handles_to_evict.clear(); |
| 1115 | for (LIRSHandle* e : tstate->handles_to_free) { |
| 1116 | Free(e); |
| 1117 | } |
| 1118 | tstate->handles_to_free.clear(); |
| 1119 | } |
| 1120 | |
| 1121 | void LIRSCacheShard::Erase(const Slice& key, uint32_t hash) { |
| 1122 | DCHECK(initialized_); |
nothing calls this directly
no test coverage detected