| 486 | } |
| 487 | |
| 488 | bool AsyncLocalReadFile::waitForComplete() { |
| 489 | auto pending = pending_.wlock(); |
| 490 | if (*pending == 0) |
| 491 | return true; |
| 492 | io_uring_cqe* cqe; |
| 493 | while (*pending > 0) { |
| 494 | int ret = io_uring_wait_cqe(ring_.get(), &cqe); |
| 495 | if (ret < 0) { |
| 496 | LOG(ERROR) << "Failed to wait for CQE with errorno " << -ret << " : " |
| 497 | << std::strerror(-ret); |
| 498 | return false; |
| 499 | } |
| 500 | if (cqe->res < 0) { |
| 501 | LOG(ERROR) << "Failed to get result with errorno " << -(cqe->res) << " : " |
| 502 | << std::strerror(-cqe->res); |
| 503 | return false; |
| 504 | } else { |
| 505 | (*pending)--; |
| 506 | io_uring_cqe_seen(ring_.get(), cqe); |
| 507 | } |
| 508 | } |
| 509 | return true; |
| 510 | } |
| 511 | |
| 512 | uint64_t AsyncLocalReadFile::size() const { |
| 513 | return size_; |