| 603 | tickDuration_ = 1s / double(tickRate); |
| 604 | } |
| 605 | Overlay::TaskScheduler::nano Overlay::TaskScheduler::GetNextWait() |
| 606 | { |
| 607 | // reset all zeros |
| 608 | for (auto&&[r, p] : vi::zip(remainings_, periods_)) { |
| 609 | if (r == 0) r = p; |
| 610 | } |
| 611 | // find the lowest remaining |
| 612 | const auto min = *rn::min_element(remainings_); |
| 613 | // step all by lowest |
| 614 | for (auto& r : remainings_) { |
| 615 | r -= min; |
| 616 | } |
| 617 | // return step duration |
| 618 | return std::chrono::duration_cast<std::chrono::nanoseconds>(tickDuration_) * min; |
| 619 | } |
| 620 | bool Overlay::TaskScheduler::AtPoll() const |
| 621 | { |
| 622 | return remainings_[Poll_] == 0; |