AppCoreThread: Clean up BaseSysExecEvent_ScopedCore usage

Seems like the ScopedCoreThreadPause parameter is legacy
and was only getting in the way of an upcoming change to that event.
This commit is contained in:
Silent 2021-09-20 21:48:02 +02:00 committed by Kojin
parent f7bcb92d9a
commit e6e7a55d7e
2 changed files with 10 additions and 11 deletions

View File

@ -774,16 +774,15 @@ void BaseScopedCoreThread::DoResume()
// Returns TRUE if the event is posted to the SysExecutor.
// Returns FALSE if the thread *is* the SysExecutor (no message is posted, calling code should
// handle the code directly).
bool BaseScopedCoreThread::PostToSysExec(BaseSysExecEvent_ScopedCore* msg)
bool BaseScopedCoreThread::PostToSysExec(std::unique_ptr<BaseSysExecEvent_ScopedCore> msg)
{
std::unique_ptr<BaseSysExecEvent_ScopedCore> smsg(msg);
if (!smsg || GetSysExecutorThread().IsSelf())
if (!msg || GetSysExecutorThread().IsSelf())
return false;
msg->SetSyncState(m_sync);
msg->SetResumeStates(m_sync_resume, m_mtx_resume);
GetSysExecutorThread().PostEvent(smsg.release());
GetSysExecutorThread().PostEvent(msg.release());
m_sync.WaitForResult();
m_sync.RethrowException();
@ -799,7 +798,7 @@ ScopedCoreThreadClose::ScopedCoreThreadClose()
return;
}
if (!PostToSysExec(new SysExecEvent_CoreThreadClose()))
if (!PostToSysExec(std::make_unique<SysExecEvent_CoreThreadClose>()))
{
m_alreadyStopped = CoreThread.IsClosed();
if (!m_alreadyStopped)
@ -821,7 +820,7 @@ ScopedCoreThreadClose::~ScopedCoreThreadClose()
DESTRUCTOR_CATCHALL
}
ScopedCoreThreadPause::ScopedCoreThreadPause(BaseSysExecEvent_ScopedCore* abuse_me)
ScopedCoreThreadPause::ScopedCoreThreadPause()
{
if (ScopedCore_IsFullyClosed || ScopedCore_IsPaused)
{
@ -830,9 +829,7 @@ ScopedCoreThreadPause::ScopedCoreThreadPause(BaseSysExecEvent_ScopedCore* abuse_
return;
}
if (!abuse_me)
abuse_me = new SysExecEvent_CoreThreadPause();
if (!PostToSysExec(abuse_me))
if (!PostToSysExec(std::make_unique<SysExecEvent_CoreThreadPause>()))
{
m_alreadyStopped = CoreThread.IsPaused();
if (!m_alreadyStopped)

View File

@ -21,6 +21,8 @@
#include "AppCommon.h"
#include "SaveState.h"
#include <memory>
#define AffinityAssert_AllowFrom_CoreThread() \
pxAssertMsg(GetCoreThread().IsSelf(), "Thread affinity violation: Call allowed from SysCoreThread only.")
@ -201,7 +203,7 @@ public:
virtual void AllowResume();
virtual void DisallowResume();
virtual bool PostToSysExec(BaseSysExecEvent_ScopedCore* msg);
virtual bool PostToSysExec(std::unique_ptr<BaseSysExecEvent_ScopedCore> msg);
protected:
// Called from destructors -- do not make virtual!!
@ -240,7 +242,7 @@ struct ScopedCoreThreadPause : public BaseScopedCoreThread
typedef BaseScopedCoreThread _parent;
public:
ScopedCoreThreadPause(BaseSysExecEvent_ScopedCore* abuse_me = NULL);
ScopedCoreThreadPause();
virtual ~ScopedCoreThreadPause();
};