diff options
author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-10-11 20:44:14 +0200 |
---|---|---|
committer | Fernando Sahmkow <fsahmkow27@gmail.com> | 2019-10-11 20:44:14 +0200 |
commit | e0650a2034026d8292196128d2f9decb50eeb0f3 (patch) | |
tree | 59c51153a985e7fb66e62c812250c6dacd69a82c /src/core/core_timing.cpp | |
parent | Core Timing: Correct Idle and remove lefting pragma (diff) | |
download | yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.tar yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.tar.gz yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.tar.bz2 yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.tar.lz yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.tar.xz yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.tar.zst yuzu-e0650a2034026d8292196128d2f9decb50eeb0f3.zip |
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r-- | src/core/core_timing.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 3ca265b4f..780c6843a 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -38,10 +38,8 @@ CoreTiming::CoreTiming() = default; CoreTiming::~CoreTiming() = default; void CoreTiming::Initialize() { - for (std::size_t core = 0; core < num_cpu_cores; core++) { - downcounts[core] = MAX_SLICE_LENGTH; - time_slice[core] = MAX_SLICE_LENGTH; - } + downcounts.fill(MAX_SLICE_LENGTH); + time_slice.fill(MAX_SLICE_LENGTH); slice_length = MAX_SLICE_LENGTH; global_timer = 0; idled_cycles = 0; @@ -162,17 +160,17 @@ std::optional<u64> CoreTiming::NextAvailableCore(const s64 needed_ticks) const { if (time_slice[next_context] >= needed_ticks) { return {next_context}; } else if (time_slice[next_context] >= 0) { - return {}; + return std::nullopt; } next_context = (next_context + 1) % num_cpu_cores; } - return {}; + return std::nullopt; } void CoreTiming::Advance() { std::unique_lock<std::mutex> guard(inner_mutex); - const int cycles_executed = accumulated_ticks; + const u64 cycles_executed = accumulated_ticks; time_slice[current_context] = std::max<s64>(0, time_slice[current_context] - accumulated_ticks); global_timer += cycles_executed; @@ -191,7 +189,8 @@ void CoreTiming::Advance() { // Still events left (scheduled in the future) if (!event_queue.empty()) { - s64 needed_ticks = std::min<s64>(event_queue.front().time - global_timer, MAX_SLICE_LENGTH); + const s64 needed_ticks = + std::min<s64>(event_queue.front().time - global_timer, MAX_SLICE_LENGTH); const auto next_core = NextAvailableCore(needed_ticks); if (next_core) { downcounts[*next_core] = needed_ticks; |