void Dispatcher::batchTasksWalk( Dispatcher::TaskBatchPtr parent, const ExecutableNode::Task &task, BatchMap ¤tBatches, TaskToBatchMap &tasksToBatches, std::set<const TaskBatch *> &ancestors ) { TaskBatchPtr batch = acquireBatch( task, currentBatches, tasksToBatches ); TaskBatches &parentRequirements = parent->requirements(); if ( std::find( parentRequirements.begin(), parentRequirements.end(), batch ) == parentRequirements.end() ) { if ( ancestors.find( batch.get() ) != ancestors.end() ) { throw IECore::Exception( ( boost::format( "Dispatched nodes cannot have cyclic dependencies. %s and %s are involved in a cycle." ) % batch->node()->relativeName( batch->node()->scriptNode() ) % parent->node()->relativeName( parent->node()->scriptNode() ) ).str() ); } parentRequirements.push_back( batch ); } ExecutableNode::Tasks taskRequirements; task.node()->requirements( task.context(), taskRequirements ); ancestors.insert( parent.get() ); for ( ExecutableNode::Tasks::const_iterator it = taskRequirements.begin(); it != taskRequirements.end(); ++it ) { batchTasksWalk( batch, *it, currentBatches, tasksToBatches, ancestors ); } ancestors.erase( parent.get() ); }
void Dispatcher::batchTasksWalk( Dispatcher::TaskBatchPtr parent, const ExecutableNode::Task &task, BatchMap ¤tBatches, TaskToBatchMap &tasksToBatches ) { TaskBatchPtr batch = acquireBatch( task, currentBatches, tasksToBatches ); TaskBatches &parentRequirements = parent->requirements(); if ( ( batch != parent ) && std::find( parentRequirements.begin(), parentRequirements.end(), batch ) == parentRequirements.end() ) { parentRequirements.push_back( batch ); } ExecutableNode::Tasks taskRequirements; task.node()->requirements( task.context(), taskRequirements ); for ( ExecutableNode::Tasks::const_iterator it = taskRequirements.begin(); it != taskRequirements.end(); ++it ) { batchTasksWalk( batch, *it, currentBatches, tasksToBatches ); } }