Lines Matching refs:e
175 void LRU_Remove(LRUHandle* e);
176 void LRU_Append(LRUHandle*list, LRUHandle* e);
177 void Ref(LRUHandle* e);
178 void Unref(LRUHandle* e);
179 bool FinishErase(LRUHandle* e);
211 for (LRUHandle* e = lru_.next; e != &lru_; ) { in ~LRUCache() local
212 LRUHandle* next = e->next; in ~LRUCache()
213 assert(e->in_cache); in ~LRUCache()
214 e->in_cache = false; in ~LRUCache()
215 assert(e->refs == 1); // Invariant of lru_ list. in ~LRUCache()
216 Unref(e); in ~LRUCache()
217 e = next; in ~LRUCache()
221 void LRUCache::Ref(LRUHandle* e) { in Ref() argument
222 if (e->refs == 1 && e->in_cache) { // If on lru_ list, move to in_use_ list. in Ref()
223 LRU_Remove(e); in Ref()
224 LRU_Append(&in_use_, e); in Ref()
226 e->refs++; in Ref()
229 void LRUCache::Unref(LRUHandle* e) { in Unref() argument
230 assert(e->refs > 0); in Unref()
231 e->refs--; in Unref()
232 if (e->refs == 0) { // Deallocate. in Unref()
233 assert(!e->in_cache); in Unref()
234 (*e->deleter)(e->key(), e->value); in Unref()
235 free(e); in Unref()
236 } else if (e->in_cache && e->refs == 1) { // No longer in use; move to lru_ list. in Unref()
237 LRU_Remove(e); in Unref()
238 LRU_Append(&lru_, e); in Unref()
242 void LRUCache::LRU_Remove(LRUHandle* e) { in LRU_Remove() argument
243 e->next->prev = e->prev; in LRU_Remove()
244 e->prev->next = e->next; in LRU_Remove()
247 void LRUCache::LRU_Append(LRUHandle* list, LRUHandle* e) { in LRU_Append() argument
249 e->next = list; in LRU_Append()
250 e->prev = list->prev; in LRU_Append()
251 e->prev->next = e; in LRU_Append()
252 e->next->prev = e; in LRU_Append()
257 LRUHandle* e = table_.Lookup(key, hash); in Lookup() local
258 if (e != NULL) { in Lookup()
259 Ref(e); in Lookup()
261 return reinterpret_cast<Cache::Handle*>(e); in Lookup()
274 LRUHandle* e = reinterpret_cast<LRUHandle*>( in Insert() local
276 e->value = value; in Insert()
277 e->deleter = deleter; in Insert()
278 e->charge = charge; in Insert()
279 e->key_length = key.size(); in Insert()
280 e->hash = hash; in Insert()
281 e->in_cache = false; in Insert()
282 e->refs = 1; // for the returned handle. in Insert()
283 memcpy(e->key_data, key.data(), key.size()); in Insert()
286 e->refs++; // for the cache's reference. in Insert()
287 e->in_cache = true; in Insert()
288 LRU_Append(&in_use_, e); in Insert()
290 FinishErase(table_.Insert(e)); in Insert()
302 return reinterpret_cast<Cache::Handle*>(e); in Insert()
307 bool LRUCache::FinishErase(LRUHandle* e) { in FinishErase() argument
308 if (e != NULL) { in FinishErase()
309 assert(e->in_cache); in FinishErase()
310 LRU_Remove(e); in FinishErase()
311 e->in_cache = false; in FinishErase()
312 usage_ -= e->charge; in FinishErase()
313 Unref(e); in FinishErase()
315 return e != NULL; in FinishErase()
326 LRUHandle* e = lru_.next; in Prune() local
327 assert(e->refs == 1); in Prune()
328 bool erased = FinishErase(table_.Remove(e->key(), e->hash)); in Prune()