| 213 | } |
| 214 | |
| 215 | Status BufferPool::ExtractBuffer( |
| 216 | ClientHandle* client, PageHandle* page_handle, BufferHandle* buffer_handle) { |
| 217 | DCHECK(page_handle->is_pinned()); |
| 218 | DCHECK(!buffer_handle->is_open()); |
| 219 | DCHECK_EQ(page_handle->client_, client); |
| 220 | |
| 221 | // If an async pin is in flight, we need to wait for it. |
| 222 | const BufferHandle* dummy; |
| 223 | RETURN_IF_ERROR(page_handle->GetBuffer(&dummy)); |
| 224 | |
| 225 | // Bring the pin count to 1 so that we're not using surplus reservations. |
| 226 | while (page_handle->pin_count() > 1) Unpin(client, page_handle); |
| 227 | |
| 228 | // Destroy the page and extract the buffer. |
| 229 | client->impl_->DestroyPageInternal(page_handle, buffer_handle); |
| 230 | DCHECK(buffer_handle->is_open()); |
| 231 | return Status::OK(); |
| 232 | } |
| 233 | |
| 234 | Status BufferPool::AllocateBuffer( |
| 235 | ClientHandle* client, int64_t len, BufferHandle* handle) { |