summaryrefslogtreecommitdiffstats
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorB3n30 <benediktthomas@gmail.com>2018-08-13 13:56:41 +0200
committerB3n30 <benediktthomas@gmail.com>2018-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
yuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.tar.gz
yuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.tar.bz2
yuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.tar.lz
yuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.tar.xz
yuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.tar.zst
yuzu-eab35c8235955a4f433a42c93ef92b1a44b9c033.zip
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;
// to the event_queue by the emu thread
static Common::MPSCQueue<Event, false> ts_queue;
+// the queue for unscheduling the events from other threads threadsafe
+static Common::MPSCQueue<std::pair<const EventType*, u64>, false> unschedule_queue;
+
constexpr int MAX_SLICE_LENGTH = 20000;
static s64 idled_cycles;
@@ -158,6 +161,10 @@ void UnscheduleEvent(const EventType* event_type, u64 userdata) {
}
}
+void UnscheduleEventThreadsafe(const EventType* event_type, u64 userdata) {
+ unschedule_queue.Push(std::make_pair(event_type, userdata));
+}
+
void RemoveEvent(const EventType* event_type) {
auto itr = std::remove_if(event_queue.begin(), event_queue.end(),
[&](const Event& e) { return e.type == event_type; });
@@ -194,6 +201,9 @@ void MoveEvents() {
void Advance() {
MoveEvents();
+ for (std::pair<const EventType*, u64> ev; unschedule_queue.Pop(ev);) {
+ UnscheduleEvent(ev.first, ev.second);
+ }
int cycles_executed = slice_length - downcount;
global_timer += cycles_executed;