本文整理汇总了C++中ThreadPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadPtr::get方法的具体用法?C++ ThreadPtr::get怎么用?C++ ThreadPtr::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreadPtr
的用法示例。
在下文中一共展示了ThreadPtr::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: threadRun
void CPUThreadPoolExecutor::threadRun(ThreadPtr thread) {
this->threadPoolHook_.registerThread();
thread->startupBaton.post();
while (true) {
auto task = taskQueue_->try_take_for(threadTimeout_);
// Handle thread stopping, either by task timeout, or
// by 'poison' task added in join() or stop().
if (UNLIKELY(!task || task.value().poison)) {
// Actually remove the thread from the list.
SharedMutex::WriteHolder w{&threadListLock_};
if (taskShouldStop(task)) {
for (auto& o : observers_) {
o->threadStopped(thread.get());
}
threadList_.remove(thread);
stoppedThreads_.add(thread);
return;
} else {
continue;
}
}
runTask(thread, std::move(task.value()));
if (UNLIKELY(threadsToStop_ > 0 && !isJoin_)) {
SharedMutex::WriteHolder w{&threadListLock_};
if (tryDecrToStop()) {
threadList_.remove(thread);
stoppedThreads_.add(thread);
return;
}
}
}
}
示例2: RemoveFromPool
void RemoveFromPool(const ThreadPtr& threadPtr)
{
m_Pool.remove_thread(threadPtr.get());
}