void Application::Terminate() { BOOST_ASSERT( m_IsInitialized == true ); // Terminate the subsystems in the opposite order as they were registered. SubsystemList::reverse_iterator iter = m_Subsystems.rbegin(); while ( iter != m_Subsystems.rend() ) { SubsystemPtr subsystem = (*iter); subsystem->Terminate(); ++iter; } m_Subsystems.clear(); // Unload any previously loaded plug-ins PluginList plugins = m_Plugins; PluginList::iterator pluginIter = plugins.begin(); while ( pluginIter != plugins.end() ) { PluginPtr plugin = (*pluginIter); plugin->Terminate(); UnloadPlugin( plugin ); ++pluginIter; } plugins.clear(); m_PluginsByName.clear(); m_PluginsByFileName.clear(); m_Plugins.clear(); // Flush all the libraries. At this point // there should be no residual pointers to objects // created in the library. m_DynamicLibSubsystem->Flush(); m_IsInitialized = false; OnTerminated( EventArgs( *this ) ); }
void CProcessLauncher::MonitorThread() { DWORD nCount = 1; HANDLE lpHandles[2] = {m_pi.hProcess, NULL}; if( m_dwMilliseconds != INFINITE ) { // 데드락을 체크한다. lpHandles[1] = m_hEvent; nCount = 2; } while( 1 ) { DWORD dw = WaitForMultipleObjectsEx( nCount, lpHandles, FALSE, m_dwMilliseconds, TRUE ); switch( dw ) { case WAIT_IO_COMPLETION: puts("WAIT_IO_COMPLETION MonitorThread end."); return; case WAIT_OBJECT_0: // 프로세스가 끝나는 경우 쓰레드종료 OnTerminated(); puts("WAIT_OBJECT_0 MonitorThread end."); return; case (WAIT_OBJECT_0 + 1): // 하트비트의 경우 TRACE( "( WAIT_OBJECT_0 + 1 )\n" ); break; case WAIT_TIMEOUT: // 타임오버 - 데드락으로 인식 CTime time = CTime::GetCurrentTime(); printf( "%s\tdeadlock\n", time.Format( "%Y/%m/%d %H:%M:%S" ) ); TerminateProcess( m_pi.hProcess, 0 ); break; } } }
void Connection::Disconnect() { if (mConnection) OnTerminated(mConnection); }