| 1390 | } |
| 1391 | |
| 1392 | Status ScanRangeSharedState::GetNextScanRange( |
| 1393 | RuntimeState* state, ScanRange** scan_range) { |
| 1394 | DCHECK(use_mt_scan_node_) << "Should only be called by MT scan nodes"; |
| 1395 | while (true) { |
| 1396 | *scan_range = scan_range_queue_.Dequeue(); |
| 1397 | if (*scan_range != nullptr) return Status::OK(); |
| 1398 | { |
| 1399 | unique_lock<mutex> l(scan_range_submission_lock_); |
| 1400 | while (scan_range_queue_.Empty() && remaining_scan_range_submissions_.Load() > 0 |
| 1401 | && !state->is_cancelled()) { |
| 1402 | range_submission_cv_.Wait(l); |
| 1403 | } |
| 1404 | } |
| 1405 | // No more work to do. |
| 1406 | if (scan_range_queue_.Empty() && remaining_scan_range_submissions_.Load() == 0) { |
| 1407 | break; |
| 1408 | } |
| 1409 | if (state->is_cancelled()) return Status::CANCELLED; |
| 1410 | } |
| 1411 | return Status::OK(); |
| 1412 | } |
| 1413 | |
| 1414 | void ScanRangeSharedState::AddCancellationHook(RuntimeState* state) { |
| 1415 | DCHECK(use_mt_scan_node_) << "Should only be called by MT scan nodes"; |
no test coverage detected