/[pcsx2_0.9.7]/trunk/pcsx2/System/SysThreadBase.cpp
ViewVC logotype

Diff of /trunk/pcsx2/System/SysThreadBase.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 31 by william, Tue Sep 7 03:24:11 2010 UTC revision 62 by william, Tue Sep 7 11:08:22 2010 UTC
# Line 81  void SysThreadBase::OnStart() Line 81  void SysThreadBase::OnStart()
81  //  //
82  void SysThreadBase::Suspend( bool isBlocking )  void SysThreadBase::Suspend( bool isBlocking )
83  {  {
84          if( IsSelf() || !IsRunning() ) return;          if (!pxAssertDev(!IsSelf(),"Suspend/Resume are not allowed from this thread.")) return;
85            if (!IsRunning()) return;
86    
87          // shortcut ExecMode check to avoid deadlocking on redundant calls to Suspend issued          // shortcut ExecMode check to avoid deadlocking on redundant calls to Suspend issued
88          // from Resume or OnResumeReady code.          // from Resume or OnResumeReady code.
# Line 98  void SysThreadBase::Suspend( bool isBloc Line 99  void SysThreadBase::Suspend( bool isBloc
99                          case ExecMode_Pausing:                          case ExecMode_Pausing:
100                          case ExecMode_Paused:                          case ExecMode_Paused:
101                                  if( !isBlocking )                                  if( !isBlocking )
102                                          throw Exception::CancelEvent( "Cannot suspend in non-blocking fashion: Another thread is pausing the VM state." );                                          throw Exception::CancelEvent( L"Cannot suspend in non-blocking fashion: Another thread is pausing the VM state." );
103                    
104                                  m_ExecMode = ExecMode_Closing;                                  m_ExecMode = ExecMode_Closing;
105                                  m_sem_Resume.Post();                                  m_sem_Resume.Post();
# Line 182  void SysThreadBase::Resume() Line 183  void SysThreadBase::Resume()
183                  {                  {
184                          Start();                          Start();
185                          if( !m_running || (m_ExecMode == ExecMode_NoThreadYet) )                          if( !m_running || (m_ExecMode == ExecMode_NoThreadYet) )
186                                  throw Exception::ThreadCreationError();                                  throw Exception::ThreadCreationError(this);
187                          if( m_ExecMode == ExecMode_Opened ) return;                          if( m_ExecMode == ExecMode_Opened ) return;
188                  }                  }
189                  // fall through...                  // fall through...
# Line 230  void SysThreadBase::OnCleanupInThread() Line 231  void SysThreadBase::OnCleanupInThread()
231  void SysThreadBase::OnSuspendInThread() {}  void SysThreadBase::OnSuspendInThread() {}
232  void SysThreadBase::OnResumeInThread( bool isSuspended ) {}  void SysThreadBase::OnResumeInThread( bool isSuspended ) {}
233    
234  void SysThreadBase::StateCheckInThread()  // Tests for Pause and Suspend/Close requests.  If the thread is trying to be paused or
235    // closed, it will enter a wait/holding pattern here in this method until the managing
236    // thread releases it.  Use the return value to detect if changes to the thread's state
237    // may have been changed (based on the rule that other threads are not allowed to modify
238    // this thread's state without pausing or closing it first, to prevent race conditions).
239    //
240    // Return value:
241    //   TRUE if the thread was paused or closed; FALSE if the thread
242    //   continued execution unimpeded.
243    bool SysThreadBase::StateCheckInThread()
244  {  {
245          switch( m_ExecMode )          switch( m_ExecMode )
246          {          {
# Line 240  void SysThreadBase::StateCheckInThread() Line 250  void SysThreadBase::StateCheckInThread()
250                          // threads should never have this state set while the thread is in any way                          // threads should never have this state set while the thread is in any way
251                          // active or alive. (for obvious reasons!!)                          // active or alive. (for obvious reasons!!)
252                          pxFailDev( "Invalid execution state detected." );                          pxFailDev( "Invalid execution state detected." );
253                  break;                  return false;
254          #endif          #endif
255    
256                  case ExecMode_Opened:                  case ExecMode_Opened:
257                          // Yup, need this a second time.  Variable state could have changed while we                          // Other cases don't need TestCancel() because its built into the various
258                          // were trying to acquire the lock above.                          // threading wait/signal actions.
259                          TestCancel();                          TestCancel();
260                  break;                  return false;
261    
262                  // -------------------------------------                  // -------------------------------------
263                  case ExecMode_Pausing:                  case ExecMode_Pausing:
# Line 291  void SysThreadBase::StateCheckInThread() Line 301  void SysThreadBase::StateCheckInThread()
301    
302                  jNO_DEFAULT;                  jNO_DEFAULT;
303          }          }
304            
305            return true;
306  }  }

Legend:
Removed from v.31  
changed lines
  Added in v.62

  ViewVC Help
Powered by ViewVC 1.1.22