Fixed the other place where tbb set_ref_count was called before finishing creating children which may throw exceptions, hopefully will fix the intermitant TBB crash when an exception is thrown.
parent
2b78eb8bec
commit
1c30b6daef
|
|
@ -118,8 +118,7 @@ namespace gtsam {
|
||||||
|
|
||||||
// If we have child tasks, start subtasks and wait for them to complete
|
// If we have child tasks, start subtasks and wait for them to complete
|
||||||
set_ref_count(1 + (int)node->children.size());
|
set_ref_count(1 + (int)node->children.size());
|
||||||
spawn(childTasks);
|
spawn_and_wait_for_all(childTasks);
|
||||||
wait_for_all();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -152,15 +151,16 @@ namespace gtsam {
|
||||||
tbb::task* execute()
|
tbb::task* execute()
|
||||||
{
|
{
|
||||||
typedef PreOrderTask<NODE, DATA, VISITOR_PRE, VISITOR_POST> PreOrderTask;
|
typedef PreOrderTask<NODE, DATA, VISITOR_PRE, VISITOR_POST> PreOrderTask;
|
||||||
// Set TBB ref count
|
|
||||||
set_ref_count(1 + (int)roots.size());
|
|
||||||
// Create data and tasks for our children
|
// Create data and tasks for our children
|
||||||
tbb::task_list tasks;
|
tbb::task_list tasks;
|
||||||
BOOST_FOREACH(const boost::shared_ptr<NODE>& root, roots)
|
BOOST_FOREACH(const boost::shared_ptr<NODE>& root, roots)
|
||||||
{
|
{
|
||||||
|
DATA rootData = visitorPre(root, myData);
|
||||||
tasks.push_back(*new(allocate_child())
|
tasks.push_back(*new(allocate_child())
|
||||||
PreOrderTask(root, visitorPre(root, myData), visitorPre, visitorPost, problemSizeThreshold));
|
PreOrderTask(root, rootData, visitorPre, visitorPost, problemSizeThreshold));
|
||||||
}
|
}
|
||||||
|
// Set TBB ref count
|
||||||
|
set_ref_count(1 + (int)roots.size());
|
||||||
// Spawn tasks
|
// Spawn tasks
|
||||||
spawn_and_wait_for_all(tasks);
|
spawn_and_wait_for_all(tasks);
|
||||||
// Return NULL
|
// Return NULL
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue