diff options
Diffstat (limited to 'src/core/core_timing.cpp')
| -rw-r--r-- | src/core/core_timing.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 5a7abcfca..c91ae9975 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp | |||
| @@ -154,7 +154,7 @@ void CoreTiming::RemoveEvent(const std::shared_ptr<EventType>& event_type) { | |||
| 154 | basic_lock.unlock(); | 154 | basic_lock.unlock(); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | std::optional<u64> CoreTiming::Advance() { | 157 | std::optional<s64> CoreTiming::Advance() { |
| 158 | advance_lock.lock(); | 158 | advance_lock.lock(); |
| 159 | basic_lock.lock(); | 159 | basic_lock.lock(); |
| 160 | global_timer = GetGlobalTimeNs().count(); | 160 | global_timer = GetGlobalTimeNs().count(); |
| @@ -170,10 +170,11 @@ std::optional<u64> CoreTiming::Advance() { | |||
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | basic_lock.lock(); | 172 | basic_lock.lock(); |
| 173 | global_timer = GetGlobalTimeNs().count(); | ||
| 173 | } | 174 | } |
| 174 | 175 | ||
| 175 | if (!event_queue.empty()) { | 176 | if (!event_queue.empty()) { |
| 176 | const u64 next_time = event_queue.front().time - global_timer; | 177 | const s64 next_time = event_queue.front().time - global_timer; |
| 177 | basic_lock.unlock(); | 178 | basic_lock.unlock(); |
| 178 | advance_lock.unlock(); | 179 | advance_lock.unlock(); |
| 179 | return next_time; | 180 | return next_time; |
| @@ -191,8 +192,10 @@ void CoreTiming::ThreadLoop() { | |||
| 191 | paused_set = false; | 192 | paused_set = false; |
| 192 | const auto next_time = Advance(); | 193 | const auto next_time = Advance(); |
| 193 | if (next_time) { | 194 | if (next_time) { |
| 194 | std::chrono::nanoseconds next_time_ns = std::chrono::nanoseconds(*next_time); | 195 | if (*next_time > 0) { |
| 195 | event.WaitFor(next_time_ns); | 196 | std::chrono::nanoseconds next_time_ns = std::chrono::nanoseconds(*next_time); |
| 197 | event.WaitFor(next_time_ns); | ||
| 198 | } | ||
| 196 | } else { | 199 | } else { |
| 197 | wait_set = true; | 200 | wait_set = true; |
| 198 | event.Wait(); | 201 | event.Wait(); |