From 54e4d90b6db4a20283b01cf56aa378ea2f1b15cb Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 9 Jan 2016 11:20:52 -0600 Subject: [PATCH] Fix assert on reset button hit. Fixes issue 9225. --- Source/Core/Core/CoreTiming.cpp | 9 +++++++++ Source/Core/Core/CoreTiming.h | 1 + Source/Core/Core/HW/ProcessorInterface.cpp | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index a8f8667e37..a6eca66e9d 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -258,6 +258,15 @@ void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata) } } +// To be used from any thread, including the CPU thread +void ScheduleEvent_AnyThread(int cyclesIntoFuture, int event_type, u64 userdata) +{ + if (Core::IsCPUThread()) + ScheduleEvent(cyclesIntoFuture, event_type, userdata); + else + ScheduleEvent_Threadsafe(cyclesIntoFuture, event_type, userdata); +} + void ClearPendingEvents() { while (first) diff --git a/Source/Core/Core/CoreTiming.h b/Source/Core/Core/CoreTiming.h index 236df47231..c87cbd55f5 100644 --- a/Source/Core/Core/CoreTiming.h +++ b/Source/Core/Core/CoreTiming.h @@ -48,6 +48,7 @@ void ScheduleEvent(int cyclesIntoFuture, int event_type, u64 userdata = 0); void ScheduleEvent_Immediate(int event_type, u64 userdata = 0); void ScheduleEvent_Threadsafe(int cyclesIntoFuture, int event_type, u64 userdata = 0); void ScheduleEvent_Threadsafe_Immediate(int event_type, u64 userdata = 0); +void ScheduleEvent_AnyThread(int cyclesIntoFuture, int event_type, u64 userdata = 0); // We only permit one event of each type in the queue at a time. void RemoveEvent(int event_type); diff --git a/Source/Core/Core/HW/ProcessorInterface.cpp b/Source/Core/Core/HW/ProcessorInterface.cpp index 470e31731e..819ee1a4cf 100644 --- a/Source/Core/Core/HW/ProcessorInterface.cpp +++ b/Source/Core/Core/HW/ProcessorInterface.cpp @@ -223,8 +223,8 @@ void ToggleResetButtonCallback(u64 userdata, int cyclesLate) void ResetButton_Tap() { - CoreTiming::ScheduleEvent_Threadsafe(0, toggleResetButton, true); - CoreTiming::ScheduleEvent_Threadsafe(243000000, toggleResetButton, false); + CoreTiming::ScheduleEvent_AnyThread(0, toggleResetButton, true); + CoreTiming::ScheduleEvent_AnyThread(243000000, toggleResetButton, false); } } // namespace ProcessorInterface