diff options
| -rw-r--r-- | src/core/core_timing.cpp | 10 | ||||
| -rw-r--r-- | src/core/core_timing.h | 1 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 2 |
3 files changed, 12 insertions, 1 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 |
| 57 | static Common::MPSCQueue<Event, false> ts_queue; | 57 | static Common::MPSCQueue<Event, false> ts_queue; |
| 58 | 58 | ||
| 59 | // the queue for unscheduling the events from other threads threadsafe | ||
| 60 | static Common::MPSCQueue<std::pair<const EventType*, u64>, false> unschedule_queue; | ||
| 61 | |||
| 59 | constexpr int MAX_SLICE_LENGTH = 20000; | 62 | constexpr int MAX_SLICE_LENGTH = 20000; |
| 60 | 63 | ||
| 61 | static s64 idled_cycles; | 64 | static s64 idled_cycles; |
| @@ -158,6 +161,10 @@ void UnscheduleEvent(const EventType* event_type, u64 userdata) { | |||
| 158 | } | 161 | } |
| 159 | } | 162 | } |
| 160 | 163 | ||
| 164 | void UnscheduleEventThreadsafe(const EventType* event_type, u64 userdata) { | ||
| 165 | unschedule_queue.Push(std::make_pair(event_type, userdata)); | ||
| 166 | } | ||
| 167 | |||
| 161 | void RemoveEvent(const EventType* event_type) { | 168 | void 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 | ||
| 195 | void Advance() { | 202 | void 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; |
diff --git a/src/core/core_timing.h b/src/core/core_timing.h index dfa161c0d..9ed757bd7 100644 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h | |||
| @@ -65,6 +65,7 @@ void ScheduleEvent(s64 cycles_into_future, const EventType* event_type, u64 user | |||
| 65 | void ScheduleEventThreadsafe(s64 cycles_into_future, const EventType* event_type, u64 userdata); | 65 | void ScheduleEventThreadsafe(s64 cycles_into_future, const EventType* event_type, u64 userdata); |
| 66 | 66 | ||
| 67 | void UnscheduleEvent(const EventType* event_type, u64 userdata); | 67 | void UnscheduleEvent(const EventType* event_type, u64 userdata); |
| 68 | void UnscheduleEventThreadsafe(const EventType* event_type, u64 userdata); | ||
| 68 | 69 | ||
| 69 | /// We only permit one event of each type in the queue at a time. | 70 | /// We only permit one event of each type in the queue at a time. |
| 70 | void RemoveEvent(const EventType* event_type); | 71 | void RemoveEvent(const EventType* event_type); |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index a1a7867ce..cf4f94822 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -167,7 +167,7 @@ void Thread::WakeAfterDelay(s64 nanoseconds) { | |||
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | void Thread::CancelWakeupTimer() { | 169 | void Thread::CancelWakeupTimer() { |
| 170 | CoreTiming::UnscheduleEvent(ThreadWakeupEventType, callback_handle); | 170 | CoreTiming::UnscheduleEventThreadsafe(ThreadWakeupEventType, callback_handle); |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | static boost::optional<s32> GetNextProcessorId(u64 mask) { | 173 | static boost::optional<s32> GetNextProcessorId(u64 mask) { |