diff options
author | Merry <git@mary.rs> | 2023-09-13 23:55:54 +0200 |
---|---|---|
committer | Merry <git@mary.rs> | 2023-09-16 08:42:45 +0200 |
commit | f70bafff1a97eb363a81666d187593584b9b7fe7 (patch) | |
tree | 693fa578865dd928dabe1bce516f5526f87a3e09 /src | |
parent | core_timing: Use a fibonacci heap (diff) | |
download | yuzu-f70bafff1a97eb363a81666d187593584b9b7fe7.tar yuzu-f70bafff1a97eb363a81666d187593584b9b7fe7.tar.gz yuzu-f70bafff1a97eb363a81666d187593584b9b7fe7.tar.bz2 yuzu-f70bafff1a97eb363a81666d187593584b9b7fe7.tar.lz yuzu-f70bafff1a97eb363a81666d187593584b9b7fe7.tar.xz yuzu-f70bafff1a97eb363a81666d187593584b9b7fe7.tar.zst yuzu-f70bafff1a97eb363a81666d187593584b9b7fe7.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core_timing.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 65f0df115..e671b270f 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -203,19 +203,31 @@ std::optional<s64> CoreTiming::Advance() { global_timer = GetGlobalTimeNs().count(); while (!event_queue.empty() && event_queue.top().time <= global_timer) { - Event evt = event_queue.top(); - event_queue.pop(); + const Event& evt = event_queue.top(); if (const auto event_type{evt.type.lock()}) { - basic_lock.unlock(); + if (evt.reschedule_time == 0) { + const auto evt_user_data = evt.user_data; + const auto evt_time = evt.time; - const auto new_schedule_time{event_type->callback( - evt.user_data, evt.time, - std::chrono::nanoseconds{GetGlobalTimeNs().count() - evt.time})}; + event_queue.pop(); - basic_lock.lock(); + basic_lock.unlock(); + + event_type->callback( + evt_user_data, evt_time, + std::chrono::nanoseconds{GetGlobalTimeNs().count() - evt_time}); + + basic_lock.lock(); + } else { + basic_lock.unlock(); + + const auto new_schedule_time{event_type->callback( + evt.user_data, evt.time, + std::chrono::nanoseconds{GetGlobalTimeNs().count() - evt.time})}; + + basic_lock.lock(); - if (evt.reschedule_time != 0) { const auto next_schedule_time{new_schedule_time.has_value() ? new_schedule_time.value().count() : evt.reschedule_time}; @@ -227,9 +239,8 @@ std::optional<s64> CoreTiming::Advance() { next_time = pause_end_time + next_schedule_time; } - auto h{event_queue.emplace(Event{next_time, event_fifo_id++, evt.user_data, - evt.type, next_schedule_time})}; - (*h).handle = h; + event_queue.update(evt.handle, Event{next_time, event_fifo_id++, evt.user_data, + evt.type, next_schedule_time, evt.handle}); } } |