Core: Remove IsHostThread
The core no longer cares which thread is the host thread. Cleaning up Android's HostThreadLock is left for another PR, in part because the HostThreadLock in NativeConfig.cpp still serves a purpose, and in part to make any issues easier to bisect.
This commit is contained in:
parent
a091ab137c
commit
9fd1d1d236
|
@ -5,37 +5,24 @@
|
|||
|
||||
#include <mutex>
|
||||
|
||||
#include "Core/Core.h"
|
||||
|
||||
// The Core only supports using a single Host thread.
|
||||
// If multiple threads want to call host functions then they need to queue
|
||||
// sequentially for access.
|
||||
// TODO: The above isn't true anymore, so we should get rid of this class.
|
||||
struct HostThreadLock
|
||||
{
|
||||
explicit HostThreadLock() : m_lock(s_host_identity_mutex) { Core::DeclareAsHostThread(); }
|
||||
explicit HostThreadLock() : m_lock(s_host_identity_mutex) {}
|
||||
|
||||
~HostThreadLock()
|
||||
{
|
||||
if (m_lock.owns_lock())
|
||||
Core::UndeclareAsHostThread();
|
||||
}
|
||||
~HostThreadLock() = default;
|
||||
|
||||
HostThreadLock(const HostThreadLock& other) = delete;
|
||||
HostThreadLock(HostThreadLock&& other) = delete;
|
||||
HostThreadLock& operator=(const HostThreadLock& other) = delete;
|
||||
HostThreadLock& operator=(HostThreadLock&& other) = delete;
|
||||
|
||||
void Lock()
|
||||
{
|
||||
m_lock.lock();
|
||||
Core::DeclareAsHostThread();
|
||||
}
|
||||
void Lock() { m_lock.lock(); }
|
||||
|
||||
void Unlock()
|
||||
{
|
||||
m_lock.unlock();
|
||||
Core::UndeclareAsHostThread();
|
||||
}
|
||||
void Unlock() { m_lock.unlock(); }
|
||||
|
||||
private:
|
||||
static std::mutex s_host_identity_mutex;
|
||||
|
|
|
@ -131,7 +131,6 @@ static Common::Event s_cpu_thread_job_finished;
|
|||
|
||||
static thread_local bool tls_is_cpu_thread = false;
|
||||
static thread_local bool tls_is_gpu_thread = false;
|
||||
static thread_local bool tls_is_host_thread = false;
|
||||
|
||||
static void EmuThread(Core::System& system, std::unique_ptr<BootParameters> boot,
|
||||
WindowSystemInfo wsi);
|
||||
|
@ -215,11 +214,6 @@ bool IsGPUThread()
|
|||
return tls_is_gpu_thread;
|
||||
}
|
||||
|
||||
bool IsHostThread()
|
||||
{
|
||||
return tls_is_host_thread;
|
||||
}
|
||||
|
||||
bool WantsDeterminism()
|
||||
{
|
||||
return s_wants_determinism;
|
||||
|
@ -334,16 +328,6 @@ void UndeclareAsGPUThread()
|
|||
tls_is_gpu_thread = false;
|
||||
}
|
||||
|
||||
void DeclareAsHostThread()
|
||||
{
|
||||
tls_is_host_thread = true;
|
||||
}
|
||||
|
||||
void UndeclareAsHostThread()
|
||||
{
|
||||
tls_is_host_thread = false;
|
||||
}
|
||||
|
||||
// For the CPU Thread only.
|
||||
static void CPUSetInitialExecutionState(bool force_paused = false)
|
||||
{
|
||||
|
|
|
@ -127,8 +127,6 @@ void DeclareAsCPUThread();
|
|||
void UndeclareAsCPUThread();
|
||||
void DeclareAsGPUThread();
|
||||
void UndeclareAsGPUThread();
|
||||
void DeclareAsHostThread();
|
||||
void UndeclareAsHostThread();
|
||||
|
||||
std::string StopMessage(bool main_thread, std::string_view message);
|
||||
|
||||
|
@ -141,7 +139,6 @@ bool IsUninitialized(Core::System& system);
|
|||
|
||||
bool IsCPUThread(); // this tells us whether we are the CPU thread.
|
||||
bool IsGPUThread();
|
||||
bool IsHostThread();
|
||||
|
||||
bool WantsDeterminism();
|
||||
|
||||
|
|
|
@ -199,8 +199,6 @@ static std::unique_ptr<Platform> GetPlatform(const optparse::Values& options)
|
|||
|
||||
int main(const int argc, char* argv[])
|
||||
{
|
||||
Core::DeclareAsHostThread();
|
||||
|
||||
const auto parser =
|
||||
CommandLineParse::CreateParser(CommandLineParse::ParserOptions::OmitGUIOptions);
|
||||
parser->add_option("-p", "--platform")
|
||||
|
|
|
@ -125,8 +125,6 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
Core::DeclareAsHostThread();
|
||||
|
||||
#ifdef __APPLE__
|
||||
// On macOS, a command line option matching the format "-psn_X_XXXXXX" is passed when
|
||||
// the application is launched for the first time. This is to set the "ProcessSerialNumber",
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <QSize>
|
||||
#include <QStyle>
|
||||
#include <QStyleHints>
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
|
||||
#include "AudioCommon/AudioCommon.h"
|
||||
|
@ -76,7 +77,7 @@ Settings::Settings()
|
|||
});
|
||||
|
||||
m_hotplug_callback_handle = g_controller_interface.RegisterDevicesChangedCallback([this] {
|
||||
if (Core::IsHostThread())
|
||||
if (qApp->thread() == QThread::currentThread())
|
||||
{
|
||||
emit DevicesChanged();
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ static void PrintUsage()
|
|||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Core::DeclareAsHostThread();
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
PrintUsage();
|
||||
|
|
|
@ -25,7 +25,6 @@ int main(int argc, char** argv)
|
|||
{
|
||||
fmt::print(stderr, "Running main() from UnitTestsMain.cpp\n");
|
||||
Common::RegisterMsgAlertHandler(TestMsgHandler);
|
||||
Core::DeclareAsHostThread();
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
Loading…
Reference in New Issue