BOOL CMainFrame::DestroyWindow() { WINDOWPLACEMENT wp; //unload dll p_dll_extension->UnloadDll(); StopThreads(); // Save window position if (!p_flags_toolbar->IsButtonChecked(ID_MAIN_TOOLBAR_MINMAX)) { GetWindowPlacement(&wp); preferences.SetValue(k_prefs_main_x, wp.rcNormalPosition.left); preferences.SetValue(k_prefs_main_y, wp.rcNormalPosition.top); preferences.SetValue(k_prefs_main_dx, wp.rcNormalPosition.right - wp.rcNormalPosition.left); preferences.SetValue(k_prefs_main_dy, wp.rcNormalPosition.bottom - wp.rcNormalPosition.top); } else { preferences.SetValue(k_prefs_main_x, _table_view_size.left); preferences.SetValue(k_prefs_main_y, _table_view_size.top); preferences.SetValue(k_prefs_main_dx, _table_view_size.right - _table_view_size.left); preferences.SetValue(k_prefs_main_dy, _table_view_size.bottom - _table_view_size.top); } return CFrameWnd::DestroyWindow(); }
void USBHost::UpdateWantDeterminism(const bool new_want_determinism) { if (new_want_determinism) StopThreads(); else if (IsOpened()) StartThreads(); }
int COpenHoldemApp::ExitInstance() { StopThreads(); DeleteAllSingletons(); stop_log(); Scintilla_ReleaseResources(); return CWinApp::ExitInstance(); }
/*! This virtual function is called before the destructor. We do this because here we can still call virtual methods. */ void flext_base::Exit() { #if FLEXT_SYS == FLEXT_SYS_MAX // according to David Z. one should do that first... if(NeedDSP()) dsp_free(thisHdr()); #endif #if FLEXT_SYS == FLEXT_SYS_PD && !defined(FLEXT_NOATTREDIT) // attribute editor window may still be open -> close it gfxstub_deleteforkey(thisHdr()); #endif #ifdef FLEXT_THREADS StopThreads(); #endif // send remaining pending messages for this object QFlush(this); // delete message lists if(bindhead) delete bindhead; // ATTENTION: the object must free all memory associated to bindings itself if(methhead) delete methhead; if(attrhead) delete attrhead; if(attrdata) delete attrdata; #if FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX if(outlets) delete[] outlets; if(inlets) { FLEXT_ASSERT(incnt > 1); for(int ix = 1; ix < incnt; ++ix) if(inlets[ix-1]) { // release proxy object #if FLEXT_SYS == FLEXT_SYS_PD pd_free(&inlets[ix-1]->obj.ob_pd); #elif FLEXT_SYS == FLEXT_SYS_MAX freeobject((object *)inlets[ix-1]); #endif } delete[] inlets; } #endif #if FLEXT_SYS == FLEXT_SYS_MAX if(indesc) { for(int i = 0; i < incnt; ++i) if(indesc[i]) delete[] indesc[i]; delete[] indesc; } if(outdesc) { for(int i = 0; i < outcnt; ++i) if(outdesc[i]) delete[] outdesc[i]; delete[] outdesc; } #endif flext_obj::Exit(); }
BOOL CMainFrame::DestroyWindow() { p_dll_extension->Unload(); StopThreads(); // Save window position WINDOWPLACEMENT wp; GetWindowPlacement(&wp); preferences.SetValue(k_prefs_main_x, wp.rcNormalPosition.left); preferences.SetValue(k_prefs_main_y, wp.rcNormalPosition.top); return CFrameWnd::DestroyWindow(); }
void Network::DeInitialize(){ _mutex.lock(); if (IsServer()) enet_host_destroy(_host); else enet_peer_disconnect_later(_peer,0); _isConnected = false; _isServer = false; StopThreads(); _mutex.unlock(); }
//============================================================================ // NThreadPool::~NThreadPool : Destructor. //---------------------------------------------------------------------------- NThreadPool::~NThreadPool(void) { // Stop the tasks // // Tasks must be stopped in the correct sequence: scheduled tasks must be // flushed to avoid queueing more work, running tasks must be allowed to // complete, and finally the threads themselves are stopped. CancelTasks(); WaitForTasks(); StopThreads(); }
int DrawApp::OnExit() { delete m_instance; delete m_server; StopThreads(); m_cfg_mgr->SaveDefinedDrawsSets(); wxConfig::Get()->Flush(); ErrorFrame::DestroyWindow(); return 0; }
/// <summary> /// Release all resources /// </summary> void KinectWindow::CleanUp() { if (m_hTimer) { CloseHandle(m_hTimer); m_hTimer = nullptr; } SafeDelete(m_pColorStream); SafeDelete(m_pDepthStream); SafeDelete(m_pSkeletonStream); SafeDelete(m_pAudioStream); SafeDelete(m_pAccelerometerStream); SafeDelete(m_pPrimaryView); SafeDelete(m_pSecondaryView); SafeDelete(m_pAudioView); SafeDelete(m_pAccelView); SafeDelete(m_pTiltAngleView); SafeDelete(m_pColorSettingsView); SafeDelete(m_pExposureSettingsView); SafeDelete(m_pSettings); ////Delete face tracker, face recognition and speech recog SafeDelete(m_pFaceTrackerStream); SafeDelete(m_pFaceRecogStream); // SafeDelete(m_pSimpleDict); SafeRelease(m_pNuiSensor); StopThreads(); if (INVALID_HANDLE_VALUE != m_hStartWindow) { CloseHandle(m_hStartWindow); m_hStartWindow = INVALID_HANDLE_VALUE; } if (INVALID_HANDLE_VALUE != m_hStopStreamEventThread) { CloseHandle(m_hStopStreamEventThread); m_hStopStreamEventThread = INVALID_HANDLE_VALUE; } }
int StopProc() { if(servercfg->debug && servercfg->log_level == 0) servercfg->log_level = 1; servercfg->server_retry = 0; int retries = 3; while(StopThreads() != 0 && retries--) sleep(1); // Signal the process thread to exit servercfg->kill_server = 1; servercfg->process_loop = 0; servercfg->process_cond.ConditionSignal(); servercfg->process_lock.MutexUnlock(); NT_print("Sending termination signal to end process"); sSleep(1); return 1; }
BOOL CMainFrame::DestroyWindow() { StopThreads(); PMainframe()->KillTimers(); // Save window position WINDOWPLACEMENT wp; GetWindowPlacement(&wp); Preferences()->SetValue(k_prefs_main_x, wp.rcNormalPosition.left); Preferences()->SetValue(k_prefs_main_y, wp.rcNormalPosition.top); write_log(Preferences()->debug_gui(), "[GUI] Going to delete the GUI\n"); write_log(Preferences()->debug_gui(), "[GUI] this = [%i]\n", this); // All OK here assert(AfxCheckMemory()); // http://www.maxinmontreal.com/forums/viewtopic.php?f=111&t=20459 // probably caused by incorrect order of deletion, // caused by incorrect position of StopThreads and KillTimers. bool success = CFrameWnd::DestroyWindow(); write_log(Preferences()->debug_gui(), "[GUI] Window deleted\n"); return success; }
void Network::InitializeServer(size_t maxPlayers) { _address.host = ENET_HOST_ANY; _address.port = 1234; _host = enet_host_create(&_address, maxPlayers, 2, 0, 0); std::cout << "Initializing server at port " << _address.port << ".\n"; if (_host == NULL) { std::cout << "An error occurred while trying to create an ENet server host.\n"; StopThreads(); } else { std::cout << "Succesfully creatinga ENet server host; server now running.\n"; _isServer = true; _isConnected = true; StartThreads(); } }
virtual void OnDereference(void) { onFileCallback->OnDereference(); StopThreads(); }
// Update is run in the user thread virtual bool Update(void) { if (threadPool.HasOutputFast() && threadPool.HasOutput()) { AutopatcherClientThreadInfo *threadInfo = threadPool.GetOutput(); threadInfo->onFileStruct.context.op=threadInfo->result; switch (threadInfo->result) { case PC_NOTICE_WILL_COPY_ON_RESTART: { client->CopyAndRestart(threadInfo->onFileStruct.fileName); if (threadInfo->onFileStruct.context.op==PC_WRITE_FILE) { // Regular file in use but we can write the temporary file. Restart and copy it over the existing onFileCallback->OnFile(&threadInfo->onFileStruct); } else { // Regular file in use but we can write the temporary file. Restart and copy it over the existing rakFree_Ex(threadInfo->onFileStruct.fileData, _FILE_AND_LINE_ ); threadInfo->onFileStruct.fileData=threadInfo->postPatchFile; onFileCallback->OnFile(&threadInfo->onFileStruct); threadInfo->onFileStruct.fileData=0; } } break; case PC_ERROR_FILE_WRITE_FAILURE: { if (threadInfo->onFileStruct.context.op==PC_WRITE_FILE) { onFileCallback->OnFile(&threadInfo->onFileStruct); } else { rakFree_Ex(threadInfo->onFileStruct.fileData, _FILE_AND_LINE_ ); threadInfo->onFileStruct.fileData=threadInfo->postPatchFile; threadInfo->onFileStruct.byteLengthOfThisFile=threadInfo->postPatchLength; onFileCallback->OnFile(&threadInfo->onFileStruct); threadInfo->onFileStruct.fileData=0; } } break; case PC_ERROR_PATCH_TARGET_MISSING: { onFileCallback->OnFile(&threadInfo->onFileStruct); client->Redownload(threadInfo->onFileStruct.fileName); } break; case PC_ERROR_PATCH_APPLICATION_FAILURE: { // Failure - signal class and download this file. onFileCallback->OnFile(&threadInfo->onFileStruct); client->Redownload(threadInfo->onFileStruct.fileName); } break; case PC_ERROR_PATCH_RESULT_CHECKSUM_FAILURE: { // Failure - signal class and download this file. onFileCallback->OnFile(&threadInfo->onFileStruct); client->Redownload(threadInfo->onFileStruct.fileName); } break; default: { if (threadInfo->onFileStruct.context.op==PC_WRITE_FILE) { onFileCallback->OnFile(&threadInfo->onFileStruct); } else { rakFree_Ex(threadInfo->onFileStruct.fileData, _FILE_AND_LINE_ ); threadInfo->onFileStruct.fileData=threadInfo->postPatchFile; onFileCallback->OnFile(&threadInfo->onFileStruct); threadInfo->onFileStruct.fileData=0; } } break; } if (threadInfo->prePatchFile) rakFree_Ex(threadInfo->prePatchFile, _FILE_AND_LINE_ ); if (threadInfo->postPatchFile) rakFree_Ex(threadInfo->postPatchFile, _FILE_AND_LINE_ ); if (threadInfo->onFileStruct.fileData) rakFree_Ex(threadInfo->onFileStruct.fileData, _FILE_AND_LINE_ ); RakNet::OP_DELETE(threadInfo, _FILE_AND_LINE_); } // If both input and output are empty, we are done. if (onFileCallback->Update()==false) canDeleteUser=true; if ( downloadComplete && canDeleteUser && threadPool.IsWorking()==false) { // Stop threads before calling OnThreadCompletion, in case the other thread starts a new instance of this thread. StopThreads(); client->OnThreadCompletion(); return false; } return true; }
virtual ~AutopatcherClientCallback(void) { StopThreads(); }
InlineFunctorProcessor::~InlineFunctorProcessor() { StopThreads(false); }
int TestApp::OnExit() { StopThreads(); return 0; }
void DeleteAllSingletons() { // Global instances. // Releasing in reverse order should be good, // but we have to be careful, as sometimes we do some work in the destructors, // that depends on other classes, e.g. the destructor of the autoconnector // needs its session_id (CSessionCounter). StopThreads(); if (p_casino_interface) { delete p_casino_interface; p_casino_interface = NULL; } if (p_handhistory) { delete p_handhistory; p_handhistory = NULL; } if (p_occlusioncheck) { delete p_occlusioncheck; p_occlusioncheck = NULL; } if (p_rebuymanagement) { delete p_rebuymanagement; p_rebuymanagement = NULL; } if (p_engine_container) { delete p_engine_container; p_engine_container = NULL; } if (p_autoconnector) { delete p_autoconnector; p_autoconnector = NULL; } if (p_version_info) { delete p_version_info; p_version_info = NULL; } if (p_tablemap_loader) { delete p_tablemap_loader; p_tablemap_loader = NULL; } if (p_filesystem_monitor) { delete p_filesystem_monitor; p_filesystem_monitor = NULL; } if (p_table_positioner) { delete p_table_positioner; p_table_positioner = NULL; } if (p_validator) { delete p_validator; p_validator = NULL; } if (p_versus) { delete p_versus; p_versus = NULL; } if (p_memory) { delete p_memory; p_memory = NULL; } if (p_perl) { delete p_perl; p_perl = NULL; } if (p_game_state) { delete p_game_state; p_game_state = NULL; } if (p_dll_extension) { delete p_dll_extension; p_dll_extension = NULL; } if (p_autoplayer) { delete p_autoplayer; p_autoplayer = NULL; } if (p_formula) { delete p_formula; p_formula = NULL; } if (p_replayframes_counter) { delete p_replayframes_counter; p_replayframes_counter = NULL; } if (p_tablemap_access) { delete p_tablemap_access; p_tablemap_access = NULL; } if (p_tablemap) { delete p_tablemap; p_tablemap = NULL; } if (p_lazyscraper) { delete p_lazyscraper; p_lazyscraper = NULL; } if (p_scraper_access) { delete p_scraper_access; p_scraper_access = NULL; } if (p_scraper) { delete p_scraper; p_scraper = NULL; } if (p_stableframescounter) { delete p_stableframescounter; p_stableframescounter = NULL; } if (p_sharedmem) { delete p_sharedmem; p_sharedmem = NULL; } if (p_sessioncounter) { delete p_sessioncounter; p_sessioncounter = NULL; } if (p_autoplayer_functions) { delete p_autoplayer_functions; p_autoplayer_functions = NULL; } if (p_configurationcheck) { delete p_configurationcheck; p_configurationcheck = NULL; } if (p_handreset_detector) { delete p_handreset_detector; p_handreset_detector = NULL; } if (p_string_match) {delete p_string_match; p_string_match = NULL; } if (p_filenames) { delete p_filenames; p_filenames = NULL; } }
void StkThreadGuiManager::StopAllThreads() { StopThreads(true); }
CThread::~CThread() { StopThreads(); }
bool DrawApp::OnInit() { /* Read params from szarp.cfg. */ #if wxUSE_UNICODE libpar_read_cmdline_w(&argc, argv); #else libpar_read_cmdline(&argc, argv); #endif #if BOOST_FILESYSTEM_VERSION == 3 boost::filesystem::wpath::imbue(std::locale("C")); #else boost::filesystem::wpath_traits::imbue(std::locale("C")); #endif if (!DrawGLApp::OnInit()) return false; SetProgName(_T("Draw 3")); //signal(SIGINT, INThandler); if (m_just_print_version) { std::cout << SZARP_VERSION << std::endl; return false; } m_server = NULL; m_db_queue = NULL; m_executor = NULL; m_remarks_handler = NULL; #ifdef __WXGTK__ libpar_init(); char *base = NULL; if (m_base == wxEmptyString) { base = libpar_getpar("", "config_prefix", 1); m_base = SC::L2S(base); free(base); } { if (m_base_type != IKS_BASE) { char *iks_server = libpar_getpar("draw3", "iks_server", 0); if (iks_server) { m_iks_server = SC::L2S(iks_server); m_base_type = IKS_BASE; free(iks_server); } char *iks_port = libpar_getpar("draw3", "iks_server_port", 0); if (iks_port) { m_iks_port = SC::L2S(iks_port); free(iks_port); } } } m_probers_from_szarp_cfg = get_probers_addresses(); #endif #ifdef MINGW32 WORD wVersionRequested = MAKEWORD(2, 2); WSADATA wsaData; WSAStartup(wVersionRequested, &wsaData); #endif /* Set logging to stderr. */ wxLog *logger = new wxLogStderr(); //wxLog *logger = new wxLogGui(); wxLog::SetActiveTarget(logger); m_instance = new szSingleInstanceChecker(_T(".szarp_m_instance_lock"), wxEmptyString, _T("draw3")); if (m_instance->IsAnotherRunning()) { if (!m_url.IsEmpty()) { if (m_url_open_in_existing) SendToRunningInstance(_T("START_URL"), m_url.c_str()); else SendToRunningInstance(_T("START_URL_EXISTING"), m_url.c_str()); } else if (!m_base.IsEmpty()) { SendToRunningInstance(_T("START_BASE"), m_base.c_str()); } else { wxLogError(_T("base not given")); return false; } return false; } InitGL(); SplashScreen *splash = NULL; wxBitmap bitmap; // this loads draw64_xpm under Linux, or draw64 icon resource under Windows szFrame::setDefaultIcon(wxICON(draw64)); wxString splashimage = GetSzarpDir(); #ifndef MINGW32 splashimage += _T("resources/wx/images/szarp-logo.png"); #else splashimage += _T("resources\\wx\\images\\szarp-logo.png"); #endif #if wxUSE_LIBPNG /* Activate PNG image handler. */ wxImage::AddHandler( new wxPNGHandler ); #endif if (bitmap.LoadFile(splashimage, wxBITMAP_TYPE_PNG)) splash = new SplashScreen(&bitmap); else splash = new SplashScreen(); splash->Show(true); splash->PushStatusText(_("Setting locale...")); /* Set locale. */ this->InitializeLocale(_T("draw3"), locale); splash->PushStatusText(_("Reading params from szarp.cfg...")); wxString _lang = wxConfig::Get()->Read(_T("LANGUAGE"), AUTO_LANGUAGE); if (_lang == AUTO_LANGUAGE) _lang = DEFAULT_LANGUAGE; splash->PushStatusText(_("Initializing IPKContainer...")); IPKContainer::Init(GetSzarpDataDir().c_str(), GetSzarpDir().c_str(), _lang.c_str()); m_cfg_mgr = new ConfigManager(GetSzarpDataDir(), IPKContainer::GetObject()); m_cfg_mgr->SetSplashScreen(splash); splash->PushStatusText(_("Initializing szbase...")); splash->PushStatusText(_("Initializing XML Resources...")); InitXmlResource(); splash->PushStatusText(_("Starting database query mechanism...")); m_db_queue = new DatabaseQueryQueue(); m_dbmgr = new DatabaseManager(m_db_queue, m_cfg_mgr); m_db_queue->SetDatabaseManager(m_dbmgr); m_dbmgr->SetProbersAddresses(GetProbersAddresses()); Draw3Base* draw_base; switch (m_base_type) { case SZBASE_BASE: draw_base = new SzbaseBase(m_dbmgr, GetSzarpDataDir().c_str(), &ConfigurationFileChangeHandler::handle, wxConfig::Get()->Read(_T("SZBUFER_IN_MEMORY_CACHE"), 0L)); break; case SZ4_BASE: draw_base = new Sz4Base(m_dbmgr, GetSzarpDataDir().c_str(), IPKContainer::GetObject()); break; case IKS_BASE: draw_base = new Sz4ApiBase(m_dbmgr, m_iks_server.c_str(), m_iks_port.c_str(), IPKContainer::GetObject()); break; } m_executor = new QueryExecutor(m_db_queue, m_dbmgr, draw_base); m_executor->Create(); m_executor->SetPriority((WXTHREAD_MAX_PRIORITY + WXTHREAD_DEFAULT_PRIORITY) / 2); m_executor->Run(); m_cfg_mgr->SetDatabaseManager(m_dbmgr); ConfigurationFileChangeHandler::database_manager = m_dbmgr; /* default config */ wxString defid; DrawsSets *config = NULL; splash->PushStatusText(_("Loading configuration...")); /* init activity logger with base name as server name. This assumes that * server has written basename to /etc/hosts on linux machines and probably * doesn't work on windows. */ UDPLogger::SetAppName( "draw3" ); UDPLogger::SetAddress( (const char*)m_base.mb_str(wxConvUTF8) ); UDPLogger::SetPort ( "7777" ); UDPLogger::LogEvent ( "drawapp:start" ); wxString prefix, window; PeriodType pt = PERIOD_T_YEAR; time_t time = -1; int selected_draw = 0; if (!m_url.IsEmpty()) { if (!decode_url(m_url, prefix, window, pt, time, selected_draw)) { wxLogError(_T("Invalid URL")); StopThreads(); return FALSE; } } else if (!m_base.IsEmpty()) { if ((config = m_cfg_mgr->LoadConfig(m_base,std::wstring(),m_show_logparams)) == NULL) { wxLogError(_("Error occurred while loading default configuration. Check your szarp.cfg file.")); StopThreads(); return FALSE; } prefix = m_base; } else { wxLogError(_("Missing starting base specification.")); StopThreads(); return FALSE; } #ifndef MINGW32 libpar_done(); #endif m_help = new szHelpController; #ifndef MINGW32 m_help->AddBook(wxGetApp().GetSzarpDir() + L"/resources/documentation/new/draw3/html/draw3.hhp"); #else m_help->AddBook(wxGetApp().GetSzarpDir() + L"\\resources\\documentation\\new\\draw3\\html\\draw3.hhp"); #endif szHelpControllerHelpProvider* provider = new szHelpControllerHelpProvider; wxHelpProvider::Set(provider); provider->SetHelpController(m_help); splash->PushStatusText(_("Initizalizing remarks...")); m_remarks_handler = new RemarksHandler(m_cfg_mgr); m_remarks_handler->Start(); splash->PushStatusText(_("Creating Frame Manager...")); VersionChecker* version_checker = new VersionChecker(argv[0]); version_checker->Start(); FrameManager *fm = new FrameManager(m_dbmgr, m_cfg_mgr, m_remarks_handler); /*@michal */ if (!fm->CreateFrame(prefix, window, pt, time, wxSize(width, height), wxPoint(x, y), selected_draw, m_url.IsEmpty(), m_full_screen)) { StopThreads(); wxLogError(_T("Unable to load base: %s"), prefix.c_str()); return FALSE; } StartInstanceServer(fm, m_cfg_mgr); wxToolTip::SetDelay(1000); SetAppName(_T("SZARPDRAW3")); splash->Destroy(); m_cfg_mgr->ResetSplashScreen(); #ifndef NO_GSTREAMER if (!gst_init_check(NULL, NULL, NULL)) return 1; #endif return TRUE; }
CCPUFrequencyMonitor::~CCPUFrequencyMonitor() { StopThreads(); }
DrawerCommandQueue::~DrawerCommandQueue() { StopThreads(); }