mirror of https://github.com/PCSX2/pcsx2.git
Qt: Implement Host::RunOnCPUThread()
This commit is contained in:
parent
577d6e735c
commit
0efe03e726
|
@ -583,6 +583,11 @@ void EmuThread::onDisplayWindowResized(int width, int height, float scale)
|
|||
|
||||
void EmuThread::onDisplayWindowFocused() {}
|
||||
|
||||
void EmuThread::runOnCPUThread(const std::function<void()>& func)
|
||||
{
|
||||
func();
|
||||
}
|
||||
|
||||
void EmuThread::updateDisplay()
|
||||
{
|
||||
pxAssertRel(!isOnEmuThread(), "Not on emu thread");
|
||||
|
@ -842,6 +847,20 @@ void Host::PumpMessagesOnCPUThread()
|
|||
g_emu_thread->getEventLoop()->processEvents(QEventLoop::AllEvents);
|
||||
}
|
||||
|
||||
void Host::RunOnCPUThread(std::function<void()> function, bool block /* = false */)
|
||||
{
|
||||
if (g_emu_thread->isOnEmuThread())
|
||||
{
|
||||
// probably shouldn't ever happen, but just in case..
|
||||
function();
|
||||
return;
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(g_emu_thread, "runOnCPUThread",
|
||||
block ? Qt::BlockingQueuedConnection : Qt::QueuedConnection,
|
||||
Q_ARG(const std::function<void()>&, std::move(function)));
|
||||
}
|
||||
|
||||
ScopedVMPause::ScopedVMPause(bool was_paused)
|
||||
: m_was_paused(was_paused)
|
||||
{
|
||||
|
|
|
@ -76,6 +76,7 @@ public Q_SLOTS:
|
|||
void requestDisplaySize(float scale);
|
||||
void enumerateInputDevices();
|
||||
void enumerateVibrationMotors();
|
||||
void runOnCPUThread(const std::function<void()>& func);
|
||||
|
||||
Q_SIGNALS:
|
||||
DisplayWidget* onCreateDisplayRequested(bool fullscreen, bool render_to_main);
|
||||
|
|
|
@ -69,10 +69,12 @@ static std::unique_ptr<INISettingsInterface> s_base_settings_interface;
|
|||
|
||||
bool QtHost::Initialize()
|
||||
{
|
||||
qRegisterMetaType<std::optional<bool>>();
|
||||
qRegisterMetaType<std::function<void()>>();
|
||||
qRegisterMetaType<std::shared_ptr<VMBootParameters>>();
|
||||
qRegisterMetaType<GSRendererType>();
|
||||
qRegisterMetaType<const GameList::Entry*>();
|
||||
qRegisterMetaType<InputBindingKey>();
|
||||
qRegisterMetaType<const GameList::Entry*>();
|
||||
|
||||
InitializeWxRubbish();
|
||||
if (!InitializeConfig())
|
||||
|
|
|
@ -20,13 +20,18 @@
|
|||
#include "pcsx2/Frontend/InputManager.h"
|
||||
#include "pcsx2/VMManager.h"
|
||||
#include <QtCore/QMetaType>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
class SettingsInterface;
|
||||
|
||||
class EmuThread;
|
||||
|
||||
Q_DECLARE_METATYPE(GSRendererType);
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<VMBootParameters>);
|
||||
Q_DECLARE_METATYPE(std::optional<bool>);
|
||||
Q_DECLARE_METATYPE(std::function<void()>);
|
||||
Q_DECLARE_METATYPE(GSRendererType);
|
||||
Q_DECLARE_METATYPE(InputBindingKey);
|
||||
|
||||
namespace QtHost
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
#include <string_view>
|
||||
#include <optional>
|
||||
|
||||
Q_DECLARE_METATYPE(std::optional<bool>);
|
||||
Q_DECLARE_METATYPE(std::function<void()>);
|
||||
|
||||
class ByteStream;
|
||||
|
||||
class QAction;
|
||||
|
|
Loading…
Reference in New Issue