mirror of https://github.com/PCSX2/pcsx2.git
System: port to std::atomic
v2: use an explicit int type for clang // multiple conversions from switch condition type // 'std::atomic<ExecutionMode>' to an integral or enumeration type v3/v4: use .load to read variable (clang 3.7) v5: add back 'std::atomic<ExecutionMode>' now that .load is used everywhere
This commit is contained in:
parent
34826c9506
commit
92078b1c58
|
@ -91,7 +91,7 @@ void SysThreadBase::Suspend( bool isBlocking )
|
||||||
{
|
{
|
||||||
ScopedLock locker( m_ExecModeMutex );
|
ScopedLock locker( m_ExecModeMutex );
|
||||||
|
|
||||||
switch( m_ExecMode )
|
switch( m_ExecMode.load() )
|
||||||
{
|
{
|
||||||
// Invalid thread state, nothing to suspend
|
// Invalid thread state, nothing to suspend
|
||||||
case ExecMode_NoThreadYet:
|
case ExecMode_NoThreadYet:
|
||||||
|
@ -196,7 +196,7 @@ void SysThreadBase::Resume()
|
||||||
// sanity checks against m_ExecMode/m_Running status, and if something doesn't feel
|
// sanity checks against m_ExecMode/m_Running status, and if something doesn't feel
|
||||||
// right, we should abort; the user may have canceled the action before it even finished.
|
// right, we should abort; the user may have canceled the action before it even finished.
|
||||||
|
|
||||||
switch( m_ExecMode )
|
switch( m_ExecMode.load() )
|
||||||
{
|
{
|
||||||
case ExecMode_Opened: return;
|
case ExecMode_Opened: return;
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ void SysThreadBase::OnResumeInThread( bool isSuspended ) {}
|
||||||
// continued execution unimpeded.
|
// continued execution unimpeded.
|
||||||
bool SysThreadBase::StateCheckInThread()
|
bool SysThreadBase::StateCheckInThread()
|
||||||
{
|
{
|
||||||
switch( m_ExecMode )
|
switch( m_ExecMode.load() )
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef PCSX2_DEVBUILD // optimize out handlers for these cases in release builds.
|
#ifdef PCSX2_DEVBUILD // optimize out handlers for these cases in release builds.
|
||||||
|
|
|
@ -63,7 +63,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
volatile ExecutionMode m_ExecMode;
|
std::atomic<ExecutionMode> m_ExecMode;
|
||||||
|
|
||||||
// This lock is used to avoid simultaneous requests to Suspend/Resume/Pause from
|
// This lock is used to avoid simultaneous requests to Suspend/Resume/Pause from
|
||||||
// contending threads.
|
// contending threads.
|
||||||
|
@ -71,7 +71,7 @@ protected:
|
||||||
|
|
||||||
// Used to wake up the thread from sleeping when it's in a suspended state.
|
// Used to wake up the thread from sleeping when it's in a suspended state.
|
||||||
Semaphore m_sem_Resume;
|
Semaphore m_sem_Resume;
|
||||||
|
|
||||||
// Used to synchronize inline changes from paused to suspended status.
|
// Used to synchronize inline changes from paused to suspended status.
|
||||||
Semaphore m_sem_ChangingExecMode;
|
Semaphore m_sem_ChangingExecMode;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ protected:
|
||||||
// Issue a Wait against this mutex for performing actions that require the thread
|
// Issue a Wait against this mutex for performing actions that require the thread
|
||||||
// to be suspended.
|
// to be suspended.
|
||||||
Mutex m_RunningLock;
|
Mutex m_RunningLock;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SysThreadBase();
|
explicit SysThreadBase();
|
||||||
virtual ~SysThreadBase() throw();
|
virtual ~SysThreadBase() throw();
|
||||||
|
@ -99,7 +99,7 @@ public:
|
||||||
|
|
||||||
bool IsClosing() const
|
bool IsClosing() const
|
||||||
{
|
{
|
||||||
return !IsRunning() || (m_ExecMode <= ExecMode_Closed) || (m_ExecMode == ExecMode_Closing);
|
return !IsRunning() || (m_ExecMode <= ExecMode_Closed) || (m_ExecMode == ExecMode_Closing);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasPendingStateChangeRequest() const
|
bool HasPendingStateChangeRequest() const
|
||||||
|
@ -107,7 +107,7 @@ public:
|
||||||
return m_ExecMode >= ExecMode_Closing;
|
return m_ExecMode >= ExecMode_Closing;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExecutionMode GetExecutionMode() const { return m_ExecMode; }
|
ExecutionMode GetExecutionMode() const { return m_ExecMode.load(); }
|
||||||
Mutex& ExecutionModeMutex() { return m_ExecModeMutex; }
|
Mutex& ExecutionModeMutex() { return m_ExecModeMutex; }
|
||||||
|
|
||||||
virtual void Suspend( bool isBlocking = true );
|
virtual void Suspend( bool isBlocking = true );
|
||||||
|
@ -172,10 +172,10 @@ protected:
|
||||||
// true anytime between plugins being initialized and plugins being shutdown. Gets
|
// true anytime between plugins being initialized and plugins being shutdown. Gets
|
||||||
// set false when plugins are shutdown, the corethread is canceled, or when an error
|
// set false when plugins are shutdown, the corethread is canceled, or when an error
|
||||||
// occurs while trying to upload a new state into the VM.
|
// occurs while trying to upload a new state into the VM.
|
||||||
volatile bool m_hasActiveMachine;
|
std::atomic<bool> m_hasActiveMachine;
|
||||||
|
|
||||||
wxString m_elf_override;
|
wxString m_elf_override;
|
||||||
|
|
||||||
SSE_MXCSR m_mxcsr_saved;
|
SSE_MXCSR m_mxcsr_saved;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -198,10 +198,10 @@ public:
|
||||||
virtual void UploadStateCopy( const VmStateBuffer& copy );
|
virtual void UploadStateCopy( const VmStateBuffer& copy );
|
||||||
|
|
||||||
virtual bool HasActiveMachine() const { return m_hasActiveMachine; }
|
virtual bool HasActiveMachine() const { return m_hasActiveMachine; }
|
||||||
|
|
||||||
virtual const wxString& GetElfOverride() const { return m_elf_override; }
|
virtual const wxString& GetElfOverride() const { return m_elf_override; }
|
||||||
virtual void SetElfOverride( const wxString& elf );
|
virtual void SetElfOverride( const wxString& elf );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _reset_stuff_as_needed();
|
void _reset_stuff_as_needed();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue