| 536 | } |
| 537 | |
| 538 | Status RequestContext::TryReadFromCache(const unique_lock<mutex>& lock, |
| 539 | ScanRange* range, bool* read_succeeded, bool* needs_buffers) { |
| 540 | DCHECK(lock.mutex() == &lock_ && lock.owns_lock()); |
| 541 | RETURN_IF_ERROR(range->ReadFromCache(lock, read_succeeded)); |
| 542 | if (!*read_succeeded) return Status::OK(); |
| 543 | |
| 544 | DCHECK(Validate()) << endl << DebugString(); |
| 545 | // The following cases are possible at this point: |
| 546 | // * The scan range doesn't have sub-ranges: |
| 547 | // ** 'range->buffer_manager_->buffer_tag' is CACHED_BUFFER and the buffer is |
| 548 | // already available to the reader. |
| 549 | // (there is nothing to do) |
| 550 | // |
| 551 | // * The scan range has sub-ranges, and 'range->buffer_manager_->buffer_tag' is: |
| 552 | // ** INTERNAL_BUFFER: the client needs to add buffers to the scan range. |
| 553 | // ** CLIENT_BUFFER: the client already provided a buffer to copy data into it. |
| 554 | *needs_buffers = range->buffer_manager_->is_internal_buffer(); |
| 555 | if (*needs_buffers) { |
| 556 | DCHECK(range->HasSubRanges()); |
| 557 | range->SetBlockedOnBuffer(); |
| 558 | // The range will be scheduled when buffers are added to it. |
| 559 | AddRangeToDisk(lock, range, ScheduleMode::BY_CALLER); |
| 560 | } else if (range->buffer_manager_->is_client_buffer()) { |
| 561 | DCHECK(range->HasSubRanges()); |
| 562 | AddRangeToDisk(lock, range, ScheduleMode::IMMEDIATELY); |
| 563 | } |
| 564 | return Status::OK(); |
| 565 | } |
| 566 | |
| 567 | Status RequestContext::AddWriteRange(WriteRange* write_range) { |
| 568 | unique_lock<mutex> lock(lock_); |
nothing calls this directly
no test coverage detected