summaryrefslogtreecommitdiffstats
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-01-14 21:48:01 +0100
committerLiam <byteslice@airmail.cc>2023-01-14 21:48:01 +0100
commit0953cdd271c0a62a9b336e66fa2d5583a633746f (patch)
treeb6f1f24811fd7be52276794b9fd45cc1f01f7cf4 /src/core/core_timing.cpp
parentMerge pull request #9605 from german77/mouse_mapping (diff)
downloadyuzu-0953cdd271c0a62a9b336e66fa2d5583a633746f.tar
yuzu-0953cdd271c0a62a9b336e66fa2d5583a633746f.tar.gz
yuzu-0953cdd271c0a62a9b336e66fa2d5583a633746f.tar.bz2
yuzu-0953cdd271c0a62a9b336e66fa2d5583a633746f.tar.lz
yuzu-0953cdd271c0a62a9b336e66fa2d5583a633746f.tar.xz
yuzu-0953cdd271c0a62a9b336e66fa2d5583a633746f.tar.zst
yuzu-0953cdd271c0a62a9b336e66fa2d5583a633746f.zip
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r--src/core/core_timing.cpp42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 0e7b5f943..6bac6722f 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -142,16 +142,24 @@ void CoreTiming::ScheduleLoopingEvent(std::chrono::nanoseconds start_time,
}
void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type,
- std::uintptr_t user_data) {
- std::scoped_lock scope{basic_lock};
- const auto itr = std::remove_if(event_queue.begin(), event_queue.end(), [&](const Event& e) {
- return e.type.lock().get() == event_type.get() && e.user_data == user_data;
- });
-
- // Removing random items breaks the invariant so we have to re-establish it.
- if (itr != event_queue.end()) {
- event_queue.erase(itr, event_queue.end());
- std::make_heap(event_queue.begin(), event_queue.end(), std::greater<>());
+ std::uintptr_t user_data, bool wait) {
+ {
+ std::scoped_lock lk{basic_lock};
+ const auto itr =
+ std::remove_if(event_queue.begin(), event_queue.end(), [&](const Event& e) {
+ return e.type.lock().get() == event_type.get() && e.user_data == user_data;
+ });
+
+ // Removing random items breaks the invariant so we have to re-establish it.
+ if (itr != event_queue.end()) {
+ event_queue.erase(itr, event_queue.end());
+ std::make_heap(event_queue.begin(), event_queue.end(), std::greater<>());
+ }
+ }
+
+ // Force any in-progress events to finish
+ if (wait) {
+ std::scoped_lock lk{advance_lock};
}
}
@@ -190,20 +198,6 @@ u64 CoreTiming::GetClockTicks() const {
return CpuCyclesToClockCycles(ticks);
}
-void CoreTiming::RemoveEvent(const std::shared_ptr<EventType>& event_type) {
- std::scoped_lock lock{basic_lock};
-
- const auto itr = std::remove_if(event_queue.begin(), event_queue.end(), [&](const Event& e) {
- return e.type.lock().get() == event_type.get();
- });
-
- // Removing random items breaks the invariant so we have to re-establish it.
- if (itr != event_queue.end()) {
- event_queue.erase(itr, event_queue.end());
- std::make_heap(event_queue.begin(), event_queue.end(), std::greater<>());
- }
-}
-
std::optional<s64> CoreTiming::Advance() {
std::scoped_lock lock{advance_lock, basic_lock};
global_timer = GetGlobalTimeNs().count();