| 192 | } |
| 193 | |
| 194 | void BufferPool::Unpin(ClientHandle* client, PageHandle* handle) { |
| 195 | DCHECK(handle->is_open()); |
| 196 | DCHECK(client->is_registered()); |
| 197 | DCHECK_EQ(handle->client_, client); |
| 198 | // If handle is pinned, we can assume that the page itself is pinned. |
| 199 | DCHECK(handle->is_pinned()); |
| 200 | Page* page = handle->page_; |
| 201 | ReservationTracker* reservation = client->impl_->reservation(); |
| 202 | reservation->ReleaseTo(page->len); |
| 203 | |
| 204 | if (--page->pin_count > 0) return; |
| 205 | if (page->pin_in_flight.Load()) { |
| 206 | // Data is not in memory - move it back to evicted. |
| 207 | client->impl_->UndoMoveEvictedToPinned(page); |
| 208 | } else { |
| 209 | // Data is in memory - move it to dirty unpinned. |
| 210 | client->impl_->MoveToDirtyUnpinned(page); |
| 211 | } |
| 212 | COUNTER_ADD(client->impl_->counters().peak_unpinned_bytes, handle->len()); |
| 213 | } |
| 214 | |
| 215 | Status BufferPool::ExtractBuffer( |
| 216 | ClientHandle* client, PageHandle* page_handle, BufferHandle* buffer_handle) { |