本文整理汇总了C++中TaskPtr::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskPtr::getParent方法的具体用法?C++ TaskPtr::getParent怎么用?C++ TaskPtr::getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskPtr
的用法示例。
在下文中一共展示了TaskPtr::getParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeTask
void ThreadGroup::executeTask(const TaskPtr& task)
{
try {
std::unique_lock<std::recursive_mutex> state_lock(execution_mtx_);
ProfilerPtr profiler = getProfiler();
Trace::Ptr interlude;
if (profiler && profiler->isEnabled()) {
TimerPtr timer = profiler->getTimer(getName());
interlude.reset(new Trace(timer, task->getName()));
}
task->execute();
} catch (const std::exception& e) {
TaskGenerator* gen = task->getParent();
if (gen) {
gen->setError(e.what());
}
} catch (const std::string& s) {
std::cerr << "Uncaught exception (string) exception: " << s << std::endl;
} catch (const csapex::Failure& assertion) {
handler_.handleAssertionFailure(assertion);
} catch (...) {
std::cerr << "Uncaught exception of unknown type and origin in execution of task " << task->getName() << "!" << std::endl;
throw;
}
}
示例2: lock
std::vector<TaskPtr> ThreadGroup::remove(TaskGenerator* generator)
{
std::vector<TaskPtr> remaining_tasks;
std::unique_lock<std::recursive_mutex> lock(tasks_mtx_);
TaskGeneratorPtr removed;
for (auto it = tasks_.begin(); it != tasks_.end();) {
TaskPtr task = *it;
if (task->getParent() == generator) {
remaining_tasks.push_back(task);
it = tasks_.erase(it);
} else {
++it;
}
}
for (auto it = generators_.begin(); it != generators_.end();) {
if (it->get() == generator) {
removed = *it;
it = generators_.erase(it);
} else {
++it;
}
}
work_available_.notify_all();
generator_connections_[generator].clear();
generator_removed(removed);
return remaining_tasks;
}