Esempio n. 1
0
ThreadPool::~ThreadPool()
{
	nonBlockStop();
	m_WaitCondition.notify();

	join();

	m_TaskMutex.lock();
	safe_delete(m_vTaskList);
	m_TaskMutex.unlock();

	m_ThreadMutex.writeLock();
		for (size_t x=0; x<m_vThreadList.size(); x++)
		{
			m_vThreadList[x]->onCompleteEvent -= delegate(this, &ThreadPool::onThreadComplete);
			m_vThreadList[x]->stop();
		}

		safe_delete(m_vThreadList);
	m_ThreadMutex.writeUnlock();

	m_ForcedMutex.writeLock();
		for (size_t x=0; x<m_vForcedList.size(); x++)
		{
			m_vForcedList[x]->onCompleteEvent -= delegate(this, &ThreadPool::onThreadComplete);
			m_vForcedList[x]->stop();
		}

		safe_delete(m_vForcedList);
	m_ForcedMutex.writeUnlock();
}
Esempio n. 2
0
ItemThread::~ItemThread()
{
    purge();

    //for some reason it blocks on stop.

    nonBlockStop();
    m_WaitCond.notify();
    join();

    if (m_pThreadManager)
        m_pThreadManager->delist(this);
}
Esempio n. 3
0
void BaseThread::stop()
{
	if (m_pPrivates->m_bPause)
		unpause();

	nonBlockStop();

	if (m_pPrivates->m_pThread)
	{
		m_pPrivates->m_pThread->interrupt();
		if (m_pPrivates->m_pThread->joinable())
		{
			m_pPrivates->m_pThread->join();
		}
	}
}
Esempio n. 4
0
void HGTController::doDownload()
{
	//header should be saved all ready so appened to it
	m_hFile.open(m_szFile, UTIL::FS::FILE_APPEND);
	m_hFile.seek(0);

	HttpHandle wc(m_szUrl.c_str());

	//wc->getProgressEvent() += delegate(this, &HGTController::onProgress);
	wc->getWriteEvent() += delegate(this, &HGTController::onWriteMemory);

	for (size_t x=0; x<m_vSuperBlockList.size(); x++)
	{
		m_pCurBlock = m_vSuperBlockList[x];

		wc->cleanUp();
		wc->setDownloadRange(m_pCurBlock->offset, m_pCurBlock->size);

		try
		{
			m_hFile.seek(m_pCurBlock->vBlockList[0]->fileOffset);
			wc->getWeb();
		}
		catch (gcException &e)
		{
			onErrorEvent(e);
			nonBlockStop();
		}
	}

	size_t fsSize = m_rvFileList.size();
	for (size_t x=0; x<fsSize; x++)
	{
		if (!HasAllFlags(m_rvFileList[x]->getFlags(), MCFFileI::FLAG_CANUSEDIFF))
			m_rvFileList[x]->addFlag(MCFFileI::FLAG_COMPLETE);
	}
}
Esempio n. 5
0
void ToolInstallThread::run()
{

	uint32 timeout = 5*60; //five mins

	while (!isStopped())
	{
		if (m_CurrentInstall != -1)
			doNextInstall();
		else
			doFirstInstall();

		if (isStopped())
			break;

		bool timedout = m_InstallWait.wait(timeout);

		if (m_bStillInstalling)
			continue;

		m_InstallLock.lock();
		uint32 size = m_dvInstallQue.size();
		m_InstallLock.unlock();

		if (timedout && size == 0)
		{
			//timeout happened. Stop
			
#ifdef WIN32
			safe_delete(m_pIPCClient);
#endif
			nonBlockStop();
			onFailedToRunEvent();
		}
	}
}