| 411 | } |
| 412 | |
| 413 | virtual void Reset(BatchParam const& param) { |
| 414 | TryLockGuard guard{single_threaded_}; |
| 415 | |
| 416 | auto at_end = false; |
| 417 | std::swap(this->at_end_, at_end); |
| 418 | |
| 419 | bool changed = this->param_.n_prefetch_batches != param.n_prefetch_batches; |
| 420 | this->param_ = param; |
| 421 | |
| 422 | this->count_ = 0; |
| 423 | |
| 424 | if (!at_end || changed) { |
| 425 | // The last iteration did not get to the end, clear the ring to start from 0. |
| 426 | this->ring_ = std::make_unique<Ring>(); |
| 427 | } |
| 428 | this->Fetch(); // Get the 0^th page, prefetch the next page. |
| 429 | } |
| 430 | |
| 431 | [[nodiscard]] auto FetchCount() const { return this->fetch_cnt_; } |
| 432 | }; |