本文整理汇总了C++中Thread::ReleaseRef方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::ReleaseRef方法的具体用法?C++ Thread::ReleaseRef怎么用?C++ Thread::ReleaseRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thread
的用法示例。
在下文中一共展示了Thread::ReleaseRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kill_thread
int kill_thread(int handle)
{
Thread *thread = static_cast<Thread*>(GetResource(handle, OBJ_THREAD));
if (thread == 0)
return E_BAD_HANDLE;
if (thread == Thread::GetRunningThread()) {
thread->ReleaseRef();
thread->Exit();
} else {
APC *apc = new APC;
apc->fCallback = kill_apc;
apc->fIsKernel = true;
apc->fData = thread;
thread->EnqueueAPC(apc);
thread->ReleaseRef();
}
return E_NO_ERROR;
}
示例2: GrimReaper
// The Grim Reaper thread reclaims resources for threads and teams that
// have exited.
int Thread::GrimReaper(void*)
{
for (;;) {
fThreadsToReap.Wait();
cpu_flags fl = DisableInterrupts();
Thread *victim = static_cast<Thread*>(fReapQueue.Dequeue());
RestoreInterrupts(fl);
// The thread may not actually get deleted here if someone else has
// a handle to it.
victim->ReleaseRef();
}
}