| 617 | } |
| 618 | |
| 619 | void LIRSCacheShard::MoveToRecencyListBack(LIRSThreadState* tstate, LIRSHandle *e, |
| 620 | bool expected_in_list) { |
| 621 | // Remove and add to the back of the list as the most recent element |
| 622 | bool in_list = e->recency_list_hook_.is_linked(); |
| 623 | CHECK(!expected_in_list || in_list); |
| 624 | bool need_trim = false; |
| 625 | if (in_list) { |
| 626 | // Is this the oldest entry in the list (the front)? |
| 627 | LIRSHandle* oldest = &recency_list_.front(); |
| 628 | // Invariant: the oldest entry in the list is always a protected entry |
| 629 | CHECK_EQ(oldest->state(), PROTECTED); |
| 630 | if (oldest == e) { |
| 631 | need_trim = true; |
| 632 | } |
| 633 | recency_list_.erase(recency_list_.iterator_to(*e)); |
| 634 | } |
| 635 | recency_list_.push_back(*e); |
| 636 | if (need_trim) { |
| 637 | TrimRecencyList(tstate); |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | void LIRSCacheShard::AddToUnprotectedList(LIRSHandle* e) { |
| 642 | DCHECK(!e->unprotected_tombstone_list_hook_.is_linked()); |