diff options
Diffstat (limited to 'src/core/core_timing.cpp')
| -rw-r--r-- | src/core/core_timing.cpp | 10 |
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 |
| 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; |