mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-08-21 18:05:20 -05:00
Core: Make RunOnCPUThread always non-blocking.
This commit is contained in:
@@ -37,34 +37,28 @@
|
||||
|
||||
static void RestartCore(const std::weak_ptr<HW::GBA::Core>& core, std::string_view rom_path = {})
|
||||
{
|
||||
Core::RunOnCPUThread(
|
||||
Core::System::GetInstance(),
|
||||
[core, rom_path = std::string(rom_path)] {
|
||||
if (auto core_ptr = core.lock())
|
||||
{
|
||||
auto& info = Config::MAIN_GBA_ROM_PATHS[core_ptr->GetCoreInfo().device_number];
|
||||
core_ptr->Stop();
|
||||
Config::SetCurrent(info, rom_path);
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& core_timing = system.GetCoreTiming();
|
||||
if (core_ptr->Start(core_timing.GetTicks()))
|
||||
return;
|
||||
Config::SetCurrent(info, Config::GetBase(info));
|
||||
core_ptr->Start(core_timing.GetTicks());
|
||||
}
|
||||
},
|
||||
false);
|
||||
Core::RunOnCPUThread(Core::System::GetInstance(), [core, rom_path = std::string(rom_path)] {
|
||||
if (auto core_ptr = core.lock())
|
||||
{
|
||||
auto& info = Config::MAIN_GBA_ROM_PATHS[core_ptr->GetCoreInfo().device_number];
|
||||
core_ptr->Stop();
|
||||
Config::SetCurrent(info, rom_path);
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& core_timing = system.GetCoreTiming();
|
||||
if (core_ptr->Start(core_timing.GetTicks()))
|
||||
return;
|
||||
Config::SetCurrent(info, Config::GetBase(info));
|
||||
core_ptr->Start(core_timing.GetTicks());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void QueueEReaderCard(const std::weak_ptr<HW::GBA::Core>& core, std::string_view card_path)
|
||||
{
|
||||
Core::RunOnCPUThread(
|
||||
Core::System::GetInstance(),
|
||||
[core, card_path = std::string(card_path)] {
|
||||
if (auto core_ptr = core.lock())
|
||||
core_ptr->EReaderQueueCard(card_path);
|
||||
},
|
||||
false);
|
||||
Core::RunOnCPUThread(Core::System::GetInstance(), [core, card_path = std::string(card_path)] {
|
||||
if (auto core_ptr = core.lock())
|
||||
core_ptr->EReaderQueueCard(card_path);
|
||||
});
|
||||
}
|
||||
|
||||
GBAWidget::GBAWidget(std::weak_ptr<HW::GBA::Core> core, const HW::GBA::CoreInfo& info,
|
||||
@@ -161,13 +155,11 @@ void GBAWidget::ToggleDisconnect()
|
||||
|
||||
m_force_disconnect = !m_force_disconnect;
|
||||
|
||||
Core::RunOnCPUThread(
|
||||
Core::System::GetInstance(),
|
||||
[core = m_core, force_disconnect = m_force_disconnect] {
|
||||
if (auto core_ptr = core.lock())
|
||||
core_ptr->SetForceDisconnect(force_disconnect);
|
||||
},
|
||||
false);
|
||||
Core::RunOnCPUThread(Core::System::GetInstance(),
|
||||
[core = m_core, force_disconnect = m_force_disconnect] {
|
||||
if (auto core_ptr = core.lock())
|
||||
core_ptr->SetForceDisconnect(force_disconnect);
|
||||
});
|
||||
}
|
||||
|
||||
void GBAWidget::LoadROM()
|
||||
@@ -224,18 +216,16 @@ void GBAWidget::DoState(bool export_state)
|
||||
if (state_path.isEmpty())
|
||||
return;
|
||||
|
||||
Core::RunOnCPUThread(
|
||||
Core::System::GetInstance(),
|
||||
[export_state, core = m_core, state_path = state_path.toStdString()] {
|
||||
if (auto core_ptr = core.lock())
|
||||
{
|
||||
if (export_state)
|
||||
core_ptr->ExportState(state_path);
|
||||
else
|
||||
core_ptr->ImportState(state_path);
|
||||
}
|
||||
},
|
||||
false);
|
||||
Core::RunOnCPUThread(Core::System::GetInstance(),
|
||||
[export_state, core = m_core, state_path = state_path.toStdString()] {
|
||||
if (auto core_ptr = core.lock())
|
||||
{
|
||||
if (export_state)
|
||||
core_ptr->ExportState(state_path);
|
||||
else
|
||||
core_ptr->ImportState(state_path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GBAWidget::ImportExportSave(bool export_save)
|
||||
@@ -255,18 +245,16 @@ void GBAWidget::ImportExportSave(bool export_save)
|
||||
if (save_path.isEmpty())
|
||||
return;
|
||||
|
||||
Core::RunOnCPUThread(
|
||||
Core::System::GetInstance(),
|
||||
[export_save, core = m_core, save_path = save_path.toStdString()] {
|
||||
if (auto core_ptr = core.lock())
|
||||
{
|
||||
if (export_save)
|
||||
core_ptr->ExportSave(save_path);
|
||||
else
|
||||
core_ptr->ImportSave(save_path);
|
||||
}
|
||||
},
|
||||
false);
|
||||
Core::RunOnCPUThread(Core::System::GetInstance(),
|
||||
[export_save, core = m_core, save_path = save_path.toStdString()] {
|
||||
if (auto core_ptr = core.lock())
|
||||
{
|
||||
if (export_save)
|
||||
core_ptr->ExportSave(save_path);
|
||||
else
|
||||
core_ptr->ImportSave(save_path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void GBAWidget::Resize(int scale)
|
||||
|
||||
Reference in New Issue
Block a user