コード例 #1
0
ファイル: PrePostProcessor.cpp プロジェクト: Bootz/nzbget
void PrePostProcessor::Stop()
{
	Thread::Stop();
	DownloadQueue* pDownloadQueue = g_pQueueCoordinator->LockQueue();

#ifndef DISABLE_PARCHECK
	m_ParCoordinator.Stop();
#endif

	if (!pDownloadQueue->GetPostQueue()->empty())
	{
		PostInfo* pPostInfo = pDownloadQueue->GetPostQueue()->front();
		if ((pPostInfo->GetStage() == PostInfo::ptUnpacking ||
			 pPostInfo->GetStage() == PostInfo::ptExecutingScript) && 
			pPostInfo->GetPostThread())
		{
			Thread* pPostThread = pPostInfo->GetPostThread();
			pPostInfo->SetPostThread(NULL);
			pPostThread->SetAutoDestroy(true);
			pPostThread->Stop();
		}
	}

	g_pQueueCoordinator->UnlockQueue();
}
コード例 #2
0
void UpdateManager::DoUpdate(string MasterUpdateFile){

	if ( CheckForUpdate(MasterUpdateFile) )
	{
		if (UpdatePackageYesOrNo())
		{
			MyThread.m_Data.Message = "";
			MyThread.m_Data.WorkingBytesDownloaded =0;
			MyThread.m_Data.State = ThreadData::ONLINEDOWNLOAD_UPDATE;

			//update
			UpdateApplicationFiles();
			
			MyThread.m_Data.Message = "";
			MyThread.m_Data.WorkingBytesDownloaded =0;
			MyThread.m_Data.State = ThreadData::UPDATE_COMPLETE_RESET;

			Util::SleepForMilisec(15); // give that above stuff time to kick in and display
			MyThread.Stop();
	
			m_pWiiManager->UnInitWii();
			exit(0);
		}
	}
}
コード例 #3
0
void ThreadingManager::signalThreadAllStop() {
    std::set<Thread *>::iterator i;
    Thread *p;
    for (i = threadSet.begin(); i != threadSet.end(); i++) {
        p = i.operator *();
        p->Stop();
    }

}
コード例 #4
0
ファイル: ThreadPool.cpp プロジェクト: BZz-xx/library
ThreadPool::~ThreadPool()
{
	while(!pool.empty())
	{
		Thread t = pool.back();
		pool.pop_back();
		t.Stop();
	}
}
コード例 #5
0
ファイル: ThreadPool.cpp プロジェクト: BZz-xx/library
void ThreadPool::Stop()
{
	for(int i = 0; i < capacity; ++i)
	{
		Thread t = pool.front();
		pool.pop_front();
		t.Stop();
	}
}
コード例 #6
0
ファイル: test-system.cpp プロジェクト: JerkWisdom/zpublic
      /**
       * \brief Test the cancelation of thread. 
       */
      void testThreadCancel()
      {
        void* ret = NULL;
        Callback obj;
        Thread th = Thread(new ThreadArgImpl<Callback>(obj, &Callback::Call2, NULL));

        th.Start(false);
        th.Stop();
        th.Join(&ret);
        
        /* on x86 it returns 0xffffffff
         * on x86-64 0xffffffffffffffff
         * so (void*)-1
         */
        CPPUNIT_ASSERT(ret == (void*)-1);
      }
コード例 #7
0
//
// This function Downloads Files read from the configuration, using anything keep in AddURI
//		<AddFile 	URI="http://wii-bolt-thrower.googlecode.com/hg/Data/BoltThrower_v0.62/boot.dol"
//					FullDownloadPath="/" OverwriteExistingFile="YES"/>
//
bool UpdateManager::DownloadFilesListedInConfiguration(bool MisssingCheckOnly)
{
	URLManager* pURLManager = m_pWiiManager->GetURLManager();

	if (pURLManager->m_Initialised) {

		if (!MisssingCheckOnly) {
			MyThread.Start(ThreadData::ONLINEDOWNLOAD_EXTRAFILES);
		}

		// download missing files
		for ( vector<FileInfo>::iterator Iter( m_pWiiManager->GetDownloadInfoBegin()); Iter !=  m_pWiiManager->GetDownloadInfoEnd() ; ++Iter )
		{
			string FullDownloadPath(WiiFile::GetGamePath() + Iter->FullDownloadPath );
			string FullDownloadPathWithoutEndSlash = FullDownloadPath.substr(0,FullDownloadPath.rfind("/"));

			string URI_FilePath ( Iter->LogicName.c_str() );
			string FileName ( FullDownloadPath + WiiFile::GetFileNameWithoutPath( URI_FilePath ) );

			if ( !(WiiFile::CheckFileExist(FileName)) )
			{
				if (MisssingCheckOnly) {
					return true;
				}
				else {
					if ( !(WiiFile::CheckFileExist(FullDownloadPathWithoutEndSlash)) ) {
						mkdir(FullDownloadPathWithoutEndSlash.c_str(), 0777);
					}

					MyThread.m_Data.Message = "downloading "+ WiiFile::GetFileNameWithoutPath(URI_FilePath);
					if ( ! pURLManager->SaveURI(URI_FilePath , FullDownloadPath ) )
						MyThread.m_Data.Message = "Not Found "+ WiiFile::GetFileNameWithoutPath(URI_FilePath);
				}
			}
		}

		if (!MisssingCheckOnly)
			MyThread.Stop();

		//Refresh music list - may have just download something
		m_pWiiManager->ScanMusicFolder();

	}
	return false;
}
コード例 #8
0
ファイル: PrePostProcessor.cpp プロジェクト: outtahere/nzbget
void PrePostProcessor::Stop()
{
	Thread::Stop();
	GuardedDownloadQueue guard = DownloadQueue::Guard();

#ifndef DISABLE_PARCHECK
	m_parCoordinator.Stop();
#endif

	if (m_curJob && m_curJob->GetPostInfo() &&
		(m_curJob->GetPostInfo()->GetStage() == PostInfo::ptUnpacking ||
		 m_curJob->GetPostInfo()->GetStage() == PostInfo::ptExecutingScript) &&
		m_curJob->GetPostInfo()->GetPostThread())
	{
		Thread* postThread = m_curJob->GetPostInfo()->GetPostThread();
		m_curJob->GetPostInfo()->SetPostThread(nullptr);
		postThread->SetAutoDestroy(true);
		postThread->Stop();
	}
}
コード例 #9
0
void Window2_Closing(Win32Window*)
{
	worker.Stop();
	worker.Close();
}
コード例 #10
0
ファイル: Thread.hpp プロジェクト: ycopy/wawo
		void StopThread() {
			if(m_thread != NULL) {
				m_thread->Stop();
				WAWO_DELETE(m_thread);
			}
		}
コード例 #11
0
ファイル: explorer.cpp プロジェクト: darkvaderXD2014/reactos
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
{
    CONTEXT("WinMain()");

    BOOL any_desktop_running = IsAnyDesktopRunning();

    BOOL startup_desktop;

    // strip extended options from the front of the command line
    String ext_options;

    while(*lpCmdLine == '-') {
        while(*lpCmdLine && !_istspace((unsigned)*lpCmdLine))
            ext_options += *lpCmdLine++;

        while(_istspace((unsigned)*lpCmdLine))
            ++lpCmdLine;
    }

     // command line option "-install" to replace previous shell application with ROS Explorer
    if (_tcsstr(ext_options,TEXT("-install"))) {
        // install ROS Explorer into the registry
        TCHAR path[MAX_PATH];

        int l = GetModuleFileName(0, path, COUNTOF(path));
        if (l) {
            HKEY hkey;

            if (!RegOpenKey(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), &hkey)) {

                ///@todo save previous shell application in config file

                RegSetValueEx(hkey, TEXT("Shell"), 0, REG_SZ, (LPBYTE)path, l*sizeof(TCHAR));
                RegCloseKey(hkey);
            }

            if (!RegOpenKey(HKEY_CURRENT_USER, TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), &hkey)) {

                ///@todo save previous shell application in config file

                RegSetValueEx(hkey, TEXT("Shell"), 0, REG_SZ, (LPBYTE)TEXT(""), l*sizeof(TCHAR));
                RegCloseKey(hkey);
            }
        }

        HWND shellWindow = GetShellWindow();

        if (shellWindow) {
            DWORD pid;

            // terminate shell process for NT like systems
            GetWindowThreadProcessId(shellWindow, &pid);
            HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);

             // On Win 9x it's sufficient to destroy the shell window.
            DestroyWindow(shellWindow);

            if (TerminateProcess(hProcess, 0))
                WaitForSingleObject(hProcess, INFINITE);

            CloseHandle(hProcess);
        }

        startup_desktop = TRUE;
    } else {
         // create desktop window and task bar only, if there is no other shell and we are
         // the first explorer instance
         // MS Explorer looks additionally into the registry entry HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\shell,
         // to decide wether it is currently configured as shell application.
        startup_desktop = !any_desktop_running;
    }


    bool autostart = !any_desktop_running;

    // disable autostart if the SHIFT key is pressed
    if (GetAsyncKeyState(VK_SHIFT) < 0)
        autostart = false;

#ifdef _DEBUG    //MF: disabled for debugging
    autostart = false;
#endif

    // If there is given the command line option "-desktop", create desktop window anyways
    if (_tcsstr(ext_options,TEXT("-desktop")))
        startup_desktop = TRUE;
#ifndef ROSSHELL
    else if (_tcsstr(ext_options,TEXT("-nodesktop")))
        startup_desktop = FALSE;

    // Don't display cabinet window in desktop mode
    if (startup_desktop && !_tcsstr(ext_options,TEXT("-explorer")))
        nShowCmd = SW_HIDE;
#endif

    if (_tcsstr(ext_options,TEXT("-noautostart")))
        autostart = false;
    else if (_tcsstr(ext_options,TEXT("-autostart")))
        autostart = true;

#ifndef __WINE__
    if (_tcsstr(ext_options,TEXT("-console"))) {
        AllocConsole();

        _dup2(_open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE), _O_RDONLY), 0);
        _dup2(_open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), 0), 1);
        _dup2(_open_osfhandle((long)GetStdHandle(STD_ERROR_HANDLE), 0), 2);

        g_Globals._log = _fdopen(1, "w");
        setvbuf(g_Globals._log, 0, _IONBF, 0);

        LOG(TEXT("starting explorer debug log\n"));
    }
#endif


    if (startup_desktop) {
         // hide the XP login screen (Credit to Nicolas Escuder)
         // another undocumented event: "Global\\msgina: ReturnToWelcome"
        if (!SetShellReadyEvent(TEXT("msgina: ShellReadyEvent")))
            SetShellReadyEvent(TEXT("Global\\msgina: ShellReadyEvent"));
    }
#ifdef ROSSHELL
    else
        return 0;    // no shell to launch, so exit immediatelly
#endif


    if (!any_desktop_running) {
        // launch the shell DDE server
        if (g_SHDOCVW_ShellDDEInit)
            (*g_SHDOCVW_ShellDDEInit)(TRUE);
    }


    bool use_gdb_stub = false;    // !IsDebuggerPresent();

    if (_tcsstr(ext_options,TEXT("-debug")))
        use_gdb_stub = true;

    if (_tcsstr(ext_options,TEXT("-break"))) {
        LOG(TEXT("debugger breakpoint"));
        __debugbreak();
    }

#ifdef _M_IX86
    // activate GDB remote debugging stub if no other debugger is running
    if (use_gdb_stub) {
        LOG(TEXT("waiting for debugger connection...\n"));

        initialize_gdb_stub();
    }
#endif

    g_Globals.init(hInstance);

    // initialize COM and OLE before creating the desktop window
    OleInit usingCOM;

    // init common controls library
    CommonControlInit usingCmnCtrl;

    g_Globals.read_persistent();

    if (startup_desktop) {
        WaitCursor wait;

        g_Globals._desktops.init();

        g_Globals._hwndDesktop = DesktopWindow::Create();
#ifdef _USE_HDESK
        g_Globals._desktops.get_current_Desktop()->_hwndDesktop = g_Globals._hwndDesktop;
#endif
    }

    if (_tcsstr(ext_options,TEXT("-?"))) {
        MessageBoxA(g_Globals._hwndDesktop,
            "/e        open cabinet window in explorer mode\r\n"
            "/root        open cabinet window in rooted mode\r\n"
            "/mdi        open cabinet window in MDI mode\r\n"
            "/sdi        open cabinet window in SDI mode\r\n"
            "\r\n"
            "-?        display command line options\r\n"
            "\r\n"
            "-desktop        start in desktop mode regardless of an already running shell\r\n"
            "-nodesktop    disable desktop mode\r\n"
            "-explorer        display cabinet window regardless of enabled desktop mode\r\n"
            "\r\n"
            "-install        replace previous shell application with ROS Explorer\r\n"
            "\r\n"
            "-noautostart    disable autostarts\r\n"
            "-autostart    enable autostarts regardless of debug build\r\n"
            "\r\n"
            "-console        open debug console\r\n"
            "\r\n"
            "-debug        activate GDB remote debugging stub\r\n"
            "-break        activate debugger breakpoint\r\n",
            "ROS Explorer - command line options", MB_OK);
    }

    Thread* pSSOThread = NULL;

    if (startup_desktop) {
        // launch SSO thread to allow message processing independent from the explorer main thread
        pSSOThread = new SSOThread;
        pSSOThread->Start();
    }

    /**TODO launching autostart programs can be moved into a background thread. */
    if (autostart) {
        const char* argv[] = {"", "s"};    // call startup routine in SESSION_START mode
        startup(2, argv);
    }

#ifndef ROSSHELL
    if (g_Globals._hwndDesktop)
        g_Globals._desktop_mode = true;
#endif


    int ret = explorer_main(hInstance, lpCmdLine, nShowCmd);


    // write configuration file
    g_Globals.write_persistent();

    if (pSSOThread) {
        pSSOThread->Stop();
        delete pSSOThread;
    }

    if (!any_desktop_running) {
        // shutdown the shell DDE server
        if (g_SHDOCVW_ShellDDEInit)
            (*g_SHDOCVW_ShellDDEInit)(FALSE);
    }

    return ret;
}