/[pcsx2_0.9.7]/branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/pcsx2/gui/ExecutorThread.cpp
ViewVC logotype

Diff of /branch/debug/0.X/0.9.X/0.9.7/ramdump-lateset/pcsx2/gui/ExecutorThread.cpp

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

revision 329 by william, Mon Dec 27 04:02:56 2010 UTC revision 330 by william, Tue Dec 28 04:24:23 2010 UTC
# Line 22  using namespace pxSizerFlags; Line 22  using namespace pxSizerFlags;
22  //  ConsoleLogSource_Event  (implementations)  //  ConsoleLogSource_Event  (implementations)
23  // --------------------------------------------------------------------------------------  // --------------------------------------------------------------------------------------
24    
25  bool ConsoleLogSource_Event::Write( const pxEvtHandler* evtHandler, const SysExecEvent* evt, const wxChar* msg ) {  bool ConsoleLogSource_Event::Write( const pxEvtQueue* evtHandler, const SysExecEvent* evt, const wxChar* msg ) {
26          return _parent::Write( pxsFmt(L"(%s:%s) ", evtHandler->GetEventHandlerName().c_str(), evt->GetEventName().c_str()) + msg );          return _parent::Write( pxsFmt(L"(%s:%s) ", evtHandler->GetEventHandlerName().c_str(), evt->GetEventName().c_str()) + msg );
27  }  }
28  bool ConsoleLogSource_Event::Warn( const pxEvtHandler* evtHandler, const SysExecEvent* evt, const wxChar* msg ) {  bool ConsoleLogSource_Event::Warn( const pxEvtQueue* evtHandler, const SysExecEvent* evt, const wxChar* msg )   {
29          return _parent::Write( pxsFmt(L"(%s:%s) ", evtHandler->GetEventHandlerName().c_str(), evt->GetEventName().c_str()) + msg );          return _parent::Write( pxsFmt(L"(%s:%s) ", evtHandler->GetEventHandlerName().c_str(), evt->GetEventName().c_str()) + msg );
30  }  }
31  bool ConsoleLogSource_Event::Error( const pxEvtHandler* evtHandler, const SysExecEvent* evt, const wxChar* msg ) {  bool ConsoleLogSource_Event::Error( const pxEvtQueue* evtHandler, const SysExecEvent* evt, const wxChar* msg ) {
32          return _parent::Write( pxsFmt(L"(%s:%s) ", evtHandler->GetEventHandlerName().c_str(), evt->GetEventName().c_str()) + msg );          return _parent::Write( pxsFmt(L"(%s:%s) ", evtHandler->GetEventHandlerName().c_str(), evt->GetEventName().c_str()) + msg );
33  }  }
34    
# Line 84  void SysExecEvent::SetException( BaseExc Line 84  void SysExecEvent::SetException( BaseExc
84  {  {
85          if( !ex ) return;          if( !ex ) return;
86    
87          ex->DiagMsg() += wxsFormat(L"(%s) ", GetEventName().c_str());          ex->DiagMsg() += pxsFmt(L"(%s) ", GetEventName().c_str());
88          //ex->UserMsg() = prefix + ex->UserMsg();          //ex->UserMsg() = prefix + ex->UserMsg();
89    
90          if( m_sync )          if( m_sync )
# Line 153  void SysExecEvent::PostResult() const Line 153  void SysExecEvent::PostResult() const
153  }  }
154    
155  // --------------------------------------------------------------------------------------  // --------------------------------------------------------------------------------------
156  //  pxEvtHandler Implementations  //  pxEvtQueue Implementations
157  // --------------------------------------------------------------------------------------  // --------------------------------------------------------------------------------------
158  pxEvtHandler::pxEvtHandler()  pxEvtQueue::pxEvtQueue()
159  {  {
160          AtomicExchange( m_Quitting, false );          AtomicExchange( m_Quitting, false );
161          m_qpc_Start = 0;          m_qpc_Start = 0;
# Line 167  pxEvtHandler::pxEvtHandler() Line 167  pxEvtHandler::pxEvtHandler()
167  // (typically these are shutdown events critical to closing the app cleanly). Once  // (typically these are shutdown events critical to closing the app cleanly). Once
168  // all such events have been processed, the thread is stopped.  // all such events have been processed, the thread is stopped.
169  //  //
170  void pxEvtHandler::ShutdownQueue()  void pxEvtQueue::ShutdownQueue()
171  {  {
172          if( m_Quitting ) return;          if( m_Quitting ) return;
173          AtomicExchange( m_Quitting, true );          AtomicExchange( m_Quitting, true );
# Line 190  struct ScopedThreadCancelDisable Line 190  struct ScopedThreadCancelDisable
190  };  };
191    
192  // isIdle  - parameter is useful for logging only (currently)  // isIdle  - parameter is useful for logging only (currently)
193  void pxEvtHandler::ProcessEvents( pxEvtList& list, bool isIdle )  void pxEvtQueue::ProcessEvents( pxEvtList& list, bool isIdle )
194  {  {
195          ScopedLock synclock( m_mtx_pending );          ScopedLock synclock( m_mtx_pending );
196            
# Line 238  void pxEvtHandler::ProcessEvents( pxEvtL Line 238  void pxEvtHandler::ProcessEvents( pxEvtL
238          }          }
239  }  }
240    
241  void pxEvtHandler::ProcessIdleEvents()  void pxEvtQueue::ProcessIdleEvents()
242  {  {
243          ProcessEvents( m_idleEvents, true );          ProcessEvents( m_idleEvents, true );
244  }  }
245    
246  void pxEvtHandler::ProcessPendingEvents()  void pxEvtQueue::ProcessPendingEvents()
247  {  {
248          ProcessEvents( m_pendingEvents );          ProcessEvents( m_pendingEvents );
249  }  }
250    
251  // This method is provided for wxWidgets API conformance.  I like to use PostEvent instead  // This method is provided for wxWidgets API conformance.  I like to use PostEvent instead
252  // since it's reminiscent of PostMessage in Windows (and behaves rather similarly).  // since it's reminiscent of PostMessage in Windows (and behaves rather similarly).
253  void pxEvtHandler::AddPendingEvent( SysExecEvent& evt )  void pxEvtQueue::AddPendingEvent( SysExecEvent& evt )
254  {  {
255          PostEvent( evt );          PostEvent( evt );
256  }  }
# Line 261  void pxEvtHandler::AddPendingEvent( SysE Line 261  void pxEvtHandler::AddPendingEvent( SysE
261  // to it automatically when the event has been executed.  If you are using a scoped event  // to it automatically when the event has been executed.  If you are using a scoped event
262  // you should use the Reference/Handle overload instead!  // you should use the Reference/Handle overload instead!
263  //  //
264  void pxEvtHandler::PostEvent( SysExecEvent* evt )  void pxEvtQueue::PostEvent( SysExecEvent* evt )
265  {  {
266          ScopedPtr<SysExecEvent> sevt( evt );          ScopedPtr<SysExecEvent> sevt( evt );
267          if( !sevt ) return;          if( !sevt ) return;
# Line 274  void pxEvtHandler::PostEvent( SysExecEve Line 274  void pxEvtHandler::PostEvent( SysExecEve
274    
275          ScopedLock synclock( m_mtx_pending );          ScopedLock synclock( m_mtx_pending );
276                    
277          pxEvtLog.Write( this, evt, wxsFormat(L"Posting event! (pending=%d, idle=%d)", m_pendingEvents.size(), m_idleEvents.size()) );          pxEvtLog.Write( this, evt, pxsFmt(L"Posting event! (pending=%d, idle=%d)", m_pendingEvents.size(), m_idleEvents.size()) );
278    
279          m_pendingEvents.push_back( sevt.DetachPtr() );          m_pendingEvents.push_back( sevt.DetachPtr() );
280          if( m_pendingEvents.size() == 1)          if( m_pendingEvents.size() == 1)
281                  m_wakeup.Post();                  m_wakeup.Post();
282  }  }
283    
284  void pxEvtHandler::PostEvent( const SysExecEvent& evt )  void pxEvtQueue::PostEvent( const SysExecEvent& evt )
285  {  {
286          PostEvent( evt.Clone() );          PostEvent( evt.Clone() );
287  }  }
288    
289  void pxEvtHandler::PostIdleEvent( SysExecEvent* evt )  void pxEvtQueue::PostIdleEvent( SysExecEvent* evt )
290  {  {
291          if( !evt ) return;          if( !evt ) return;
292    
# Line 298  void pxEvtHandler::PostIdleEvent( SysExe Line 298  void pxEvtHandler::PostIdleEvent( SysExe
298    
299          ScopedLock synclock( m_mtx_pending );          ScopedLock synclock( m_mtx_pending );
300    
301          pxEvtLog.Write( this, evt, wxsFormat(L"Posting event! (pending=%d, idle=%d) [idle]", m_pendingEvents.size(), m_idleEvents.size()) );          pxEvtLog.Write( this, evt, pxsFmt(L"Posting event! (pending=%d, idle=%d) [idle]", m_pendingEvents.size(), m_idleEvents.size()) );
302    
303          if( m_pendingEvents.size() == 0)          if( m_pendingEvents.size() == 0)
304          {          {
# Line 309  void pxEvtHandler::PostIdleEvent( SysExe Line 309  void pxEvtHandler::PostIdleEvent( SysExe
309                  m_idleEvents.push_back( evt );                  m_idleEvents.push_back( evt );
310  }  }
311    
312  void pxEvtHandler::PostIdleEvent( const SysExecEvent& evt )  void pxEvtQueue::PostIdleEvent( const SysExecEvent& evt )
313  {  {
314          PostIdleEvent( evt.Clone() );          PostIdleEvent( evt.Clone() );
315  }  }
316    
317  void pxEvtHandler::ProcessEvent( SysExecEvent& evt )  void pxEvtQueue::ProcessEvent( SysExecEvent& evt )
318  {  {
319          if( wxThread::GetCurrentId() != m_OwnerThreadId )          if( wxThread::GetCurrentId() != m_OwnerThreadId )
320          {          {
# Line 327  void pxEvtHandler::ProcessEvent( SysExec Line 327  void pxEvtHandler::ProcessEvent( SysExec
327                  evt._DoInvokeEvent();                  evt._DoInvokeEvent();
328  }  }
329    
330  void pxEvtHandler::ProcessEvent( SysExecEvent* evt )  void pxEvtQueue::ProcessEvent( SysExecEvent* evt )
331  {  {
332          if( !evt ) return;          if( !evt ) return;
333    
# Line 345  void pxEvtHandler::ProcessEvent( SysExec Line 345  void pxEvtHandler::ProcessEvent( SysExec
345          }          }
346  }  }
347    
348  bool pxEvtHandler::Rpc_TryInvokeAsync( FnType_Void* method, const wxChar* traceName )  bool pxEvtQueue::Rpc_TryInvokeAsync( FnType_Void* method, const wxChar* traceName )
349  {  {
350          if( wxThread::GetCurrentId() != m_OwnerThreadId )          if( wxThread::GetCurrentId() != m_OwnerThreadId )
351          {          {
# Line 356  bool pxEvtHandler::Rpc_TryInvokeAsync( F Line 356  bool pxEvtHandler::Rpc_TryInvokeAsync( F
356          return false;          return false;
357  }  }
358    
359  bool pxEvtHandler::Rpc_TryInvoke( FnType_Void* method, const wxChar* traceName )  bool pxEvtQueue::Rpc_TryInvoke( FnType_Void* method, const wxChar* traceName )
360  {  {
361          if( wxThread::GetCurrentId() != m_OwnerThreadId )          if( wxThread::GetCurrentId() != m_OwnerThreadId )
362          {          {
# Line 376  bool pxEvtHandler::Rpc_TryInvoke( FnType Line 376  bool pxEvtHandler::Rpc_TryInvoke( FnType
376  // This method invokes the derived class Idle implementations (if any) and then enters  // This method invokes the derived class Idle implementations (if any) and then enters
377  // the sleep state until such time that new messages are received.  // the sleep state until such time that new messages are received.
378  //  //
 // FUTURE: Processes idle messages from the idle message queue (not implemented yet).  
 //  
379  // Extending: Derived classes should override _DoIdle instead, unless it is necessary  // Extending: Derived classes should override _DoIdle instead, unless it is necessary
380  // to implement post-wakeup behavior.  // to implement post-wakeup behavior.
381  //  //
382  void pxEvtHandler::Idle()  void pxEvtQueue::Idle()
383  {  {
384          ProcessIdleEvents();          ProcessIdleEvents();
385          _DoIdle();          _DoIdle();
386          m_wakeup.WaitWithoutYield();          m_wakeup.WaitWithoutYield();
387  }  }
388    
389  void pxEvtHandler::SetActiveThread()  void pxEvtQueue::SetActiveThread()
390  {  {
391          m_OwnerThreadId = wxThread::GetCurrentId();          m_OwnerThreadId = wxThread::GetCurrentId();
392  }  }
# Line 454  void WaitingForThreadedTaskDialog::OnTer Line 452  void WaitingForThreadedTaskDialog::OnTer
452  // --------------------------------------------------------------------------------------  // --------------------------------------------------------------------------------------
453  //  ExecutorThread Implementations  //  ExecutorThread Implementations
454  // --------------------------------------------------------------------------------------  // --------------------------------------------------------------------------------------
455  ExecutorThread::ExecutorThread( pxEvtHandler* evthandler )  ExecutorThread::ExecutorThread( pxEvtQueue* evthandler )
456  {  {
457          m_EvtHandler = evthandler;          m_EvtHandler = evthandler;
458  }  }
# Line 465  bool ExecutorThread::IsRunning() const Line 463  bool ExecutorThread::IsRunning() const
463          return( !m_EvtHandler->IsShuttingDown() );          return( !m_EvtHandler->IsShuttingDown() );
464  }  }
465    
466  // Exposes the internal pxEvtHandler::ShutdownQueue API.  See pxEvtHandler for details.  // Exposes the internal pxEvtQueue::ShutdownQueue API.  See pxEvtQueue for details.
467  void ExecutorThread::ShutdownQueue()  void ExecutorThread::ShutdownQueue()
468  {  {
469          if( !m_EvtHandler ) return;          if( !m_EvtHandler ) return;
# Line 476  void ExecutorThread::ShutdownQueue() Line 474  void ExecutorThread::ShutdownQueue()
474          Block();          Block();
475  }  }
476    
477  // Exposes the internal pxEvtHandler::PostEvent API.  See pxEvtHandler for details.  // Exposes the internal pxEvtQueue::PostEvent API.  See pxEvtQueue for details.
478  void ExecutorThread::PostEvent( SysExecEvent* evt )  void ExecutorThread::PostEvent( SysExecEvent* evt )
479  {  {
480          if( !pxAssert( m_EvtHandler ) ) { delete evt; return; }          if( !pxAssert( m_EvtHandler ) ) { delete evt; return; }
# Line 489  void ExecutorThread::PostEvent( const Sy Line 487  void ExecutorThread::PostEvent( const Sy
487          m_EvtHandler->PostEvent( evt );          m_EvtHandler->PostEvent( evt );
488  }  }
489    
490  // Exposes the internal pxEvtHandler::PostIdleEvent API.  See pxEvtHandler for details.  // Exposes the internal pxEvtQueue::PostIdleEvent API.  See pxEvtQueue for details.
491  void ExecutorThread::PostIdleEvent( SysExecEvent* evt )  void ExecutorThread::PostIdleEvent( SysExecEvent* evt )
492  {  {
493          if( !pxAssert( m_EvtHandler ) ) return;          if( !pxAssert( m_EvtHandler ) ) return;
# Line 502  void ExecutorThread::PostIdleEvent( cons Line 500  void ExecutorThread::PostIdleEvent( cons
500          m_EvtHandler->PostIdleEvent( evt );          m_EvtHandler->PostIdleEvent( evt );
501  }  }
502    
503  // Exposes the internal pxEvtHandler::ProcessEvent API.  See pxEvtHandler for details.  // Exposes the internal pxEvtQueue::ProcessEvent API.  See pxEvtQueue for details.
504  void ExecutorThread::ProcessEvent( SysExecEvent* evt )  void ExecutorThread::ProcessEvent( SysExecEvent* evt )
505  {  {
506          if( m_EvtHandler )          if( m_EvtHandler )

Legend:
Removed from v.329  
changed lines
  Added in v.330

  ViewVC Help
Powered by ViewVC 1.1.22