| 176 | } |
| 177 | |
| 178 | Status BufferPool::Pin(ClientHandle* client, PageHandle* handle) { |
| 179 | DCHECK(client->is_registered()); |
| 180 | DCHECK(handle->is_open()); |
| 181 | DCHECK_EQ(handle->client_, client); |
| 182 | |
| 183 | Page* page = handle->page_; |
| 184 | if (page->pin_count == 0) { |
| 185 | RETURN_IF_ERROR(client->impl_->StartMoveToPinned(client, page)); |
| 186 | COUNTER_ADD(client->impl_->counters().peak_unpinned_bytes, -page->len); |
| 187 | } |
| 188 | // Update accounting last to avoid complicating the error return path above. |
| 189 | ++page->pin_count; |
| 190 | client->impl_->reservation()->AllocateFrom(page->len); |
| 191 | return Status::OK(); |
| 192 | } |
| 193 | |
| 194 | void BufferPool::Unpin(ClientHandle* client, PageHandle* handle) { |
| 195 | DCHECK(handle->is_open()); |