| 228 | } |
| 229 | |
| 230 | void Emulator::CallFromMainThread(std::function<void()>&& func, atomic_t<u32>* wake_up, bool track_emu_state, u64 stop_ctr, std::source_location src_loc) const |
| 231 | { |
| 232 | std::function<void()> final_func = [this, before = IsStopped(), track_emu_state, thread_name = thread_ctrl::get_name(), src = src_loc, count = (stop_ctr == umax ? +m_stop_ctr : stop_ctr), func = std::move(func)] |
| 233 | { |
| 234 | const bool call_it = (!track_emu_state || (count == m_stop_ctr && before == IsStopped())); |
| 235 | |
| 236 | sys_log.trace("Callback from thread '%s' at [%s] is %s", thread_name, src, call_it ? "called" : "skipped"); |
| 237 | |
| 238 | if (call_it) |
| 239 | { |
| 240 | func(); |
| 241 | } |
| 242 | }; |
| 243 | |
| 244 | m_cb.call_from_main_thread(std::move(final_func), wake_up); |
| 245 | } |
| 246 | |
| 247 | void Emulator::BlockingCallFromMainThread(std::function<void()>&& func, std::source_location src_loc) const |
| 248 | { |
no outgoing calls
no test coverage detected