summaryrefslogtreecommitdiff
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorGravatar B3n302018-08-13 13:56:41 +0200
committerGravatar B3n302018-08-13 13:56:41 +0200
commiteab35c8235955a4f433a42c93ef92b1a44b9c033 (patch)
tree7f2a69b135356f49b7565004e7b277fa6d375c8b /src/core/core_timing.cpp
parentMerge pull request #1032 from lioncash/sanitize (diff)
downloadyuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.tar.gz
yuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.tar.xz
yuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.zip
Core::CoreTiming: add UnscheduleEventThreadsafe
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r--src/core/core_timing.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index f977d1b32..7953c8720 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -56,6 +56,9 @@ static u64 event_fifo_id;
56// to the event_queue by the emu thread 56// to the event_queue by the emu thread
57static Common::MPSCQueue<Event, false> ts_queue; 57static Common::MPSCQueue<Event, false> ts_queue;
58 58
59// the queue for unscheduling the events from other threads threadsafe
60static Common::MPSCQueue<std::pair<const EventType*, u64>, false> unschedule_queue;
61
59constexpr int MAX_SLICE_LENGTH = 20000; 62constexpr int MAX_SLICE_LENGTH = 20000;
60 63
61static s64 idled_cycles; 64static s64 idled_cycles;
@@ -158,6 +161,10 @@ void UnscheduleEvent(const EventType* event_type, u64 userdata) {
158 } 161 }
159} 162}
160 163
164void UnscheduleEventThreadsafe(const EventType* event_type, u64 userdata) {
165 unschedule_queue.Push(std::make_pair(event_type, userdata));
166}
167
161void RemoveEvent(const EventType* event_type) { 168void RemoveEvent(const EventType* event_type) {
162 auto itr = std::remove_if(event_queue.begin(), event_queue.end(), 169 auto itr = std::remove_if(event_queue.begin(), event_queue.end(),
163 [&](const Event& e) { return e.type == event_type; }); 170 [&](const Event& e) { return e.type == event_type; });
@@ -194,6 +201,9 @@ void MoveEvents() {
194 201
195void Advance() { 202void Advance() {
196 MoveEvents(); 203 MoveEvents();
204 for (std::pair<const EventType*, u64> ev; unschedule_queue.Pop(ev);) {
205 UnscheduleEvent(ev.first, ev.second);
206 }
197 207
198 int cycles_executed = slice_length - downcount; 208 int cycles_executed = slice_length - downcount;
199 global_timer += cycles_executed; 209 global_timer += cycles_executed;