当前位置: 首页>>代码示例>>C++>>正文


C++ Thread::Kill方法代码示例

本文整理汇总了C++中Thread::Kill方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::Kill方法的具体用法?C++ Thread::Kill怎么用?C++ Thread::Kill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thread的用法示例。


在下文中一共展示了Thread::Kill方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ExitCurrent

void Thread::ExitCurrent() {
  // no point creating a ScopedCritical; it would never be destroyed
  anarch::SetCritical(true);
  
  // since this thread is already running, it must be retained
  Thread * th = GetCurrent();
  th->Kill();
  
  // the scheduler will never be able to retain this thread again, so this will
  // be the last line of code ever run on this thread
  th->GetTask().GetScheduler().Yield();
  
  __builtin_unreachable();
}
开发者ID:CarterTsai,项目名称:alux,代码行数:14,代码来源:thread.cpp

示例2: WaitJobs

void PrePostProcessor::WaitJobs()
{
	debug("PrePostProcessor: waiting for jobs to complete");

	// wait 5 seconds until all post-processing jobs gracefully finish
	time_t waitStart = Util::CurrentTime();
	while (Util::CurrentTime() < waitStart + 5)
	{
		{
			GuardedDownloadQueue downloadQueue = DownloadQueue::Guard();
			if (m_activeJobs.empty())
			{
				break;
			}
		}
		CheckPostQueue();
		usleep(200 * 1000);
	}

	// kill remaining post-processing jobs; not safe but we can't wait any longer
	{
		GuardedDownloadQueue downloadQueue = DownloadQueue::Guard();
		for (NzbInfo* postJob : m_activeJobs)
		{
			if (postJob->GetPostInfo() && postJob->GetPostInfo()->GetPostThread())
			{
				Thread* thread = postJob->GetPostInfo()->GetPostThread();
				postJob->GetPostInfo()->SetPostThread(nullptr);
				warn("Terminating active post-process job for %s", postJob->GetName());
				thread->Kill();
				delete thread;
			}
		}
	}

	// wait 5 seconds until direct unpack threads gracefully finish
	waitStart = Util::CurrentTime();
	while (Util::CurrentTime() < waitStart + 5)
	{
		{
			GuardedDownloadQueue downloadQueue = DownloadQueue::Guard();
			if (std::find_if(downloadQueue->GetQueue()->begin(),
				downloadQueue->GetQueue()->end(),
				[](const std::unique_ptr<NzbInfo>& nzbInfo)
				{
					return nzbInfo->GetUnpackThread() != nullptr;
				}) == downloadQueue->GetQueue()->end())
			{
				break;
			}
		}
		usleep(200 * 1000);
	}

	// disconnect remaining direct unpack jobs
	{
		GuardedDownloadQueue downloadQueue = DownloadQueue::Guard();
		for (NzbInfo* nzbInfo : downloadQueue->GetQueue())
		{
			nzbInfo->SetUnpackThread(nullptr);
		}
	}

	debug("PrePostProcessor: Jobs are completed");
}
开发者ID:sanderjo,项目名称:nzbget,代码行数:65,代码来源:PrePostProcessor.cpp

示例3: kill

	/*! Kill timer thread.
	  \param sig signal to kill with */
   void kill(const int sig=SIGKILL) { _thread.Kill(sig); }
开发者ID:capitalk,项目名称:fix8,代码行数:3,代码来源:timer.hpp


注:本文中的Thread::Kill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。