Skip to content

Commit 5cd2aad

Browse files
committed
Simple execution refactoring
1 parent 23a9083 commit 5cd2aad

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/Dataflow/Engine/Controller/NetworkEditorController.cc

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ void NetworkEditorController::loadNetwork(const NetworkFileHandle& xml)
296296
{
297297
ModuleHandle module = theNetwork_->module(i);
298298
moduleAdded_(module->get_module_name(), module, modulesDone);
299-
networkDoneLoading_(i);
299+
networkDoneLoading_(static_cast<int>(i));
300300
}
301301

302302
{
@@ -340,28 +340,34 @@ void NetworkEditorController::clear()
340340

341341
void NetworkEditorController::executeAll(const ExecutableLookup* lookup)
342342
{
343-
if (!currentExecutor_)
344-
{
345-
currentExecutor_ = executorFactory_->createDefault();
346-
}
343+
initExecutor();
347344

348345
ExecuteAllModules filter;
349-
theNetwork_->setModuleExecutionState(ModuleInterface::Waiting, filter);
350-
ExecutionContext context(*theNetwork_, lookup ? *lookup : *theNetwork_, filter);
351-
currentExecutor_->execute(context);
346+
auto context = createExecutionContext(lookup, filter);
347+
currentExecutor_->execute(*context);
352348
}
353349

354350
void NetworkEditorController::executeModule(const ModuleHandle& module, const ExecutableLookup* lookup)
351+
{
352+
initExecutor();
353+
354+
ExecuteSingleModule filter(module, *theNetwork_);
355+
auto context = createExecutionContext(lookup, filter);
356+
currentExecutor_->execute(*context);
357+
}
358+
359+
void NetworkEditorController::initExecutor()
355360
{
356361
if (!currentExecutor_)
357362
{
358363
currentExecutor_ = executorFactory_->createDefault();
359364
}
365+
}
360366

361-
ExecuteSingleModule filter(module, *theNetwork_);
367+
ExecutionContextHandle NetworkEditorController::createExecutionContext(const ExecutableLookup* lookup, ModuleFilter filter)
368+
{
362369
theNetwork_->setModuleExecutionState(ModuleInterface::Waiting, filter);
363-
ExecutionContext context(*theNetwork_, lookup ? *lookup : *theNetwork_, filter);
364-
currentExecutor_->execute(context);
370+
return boost::make_shared<ExecutionContext>(*theNetwork_, lookup ? *lookup : *theNetwork_, filter);
365371
}
366372

367373
NetworkHandle NetworkEditorController::getNetwork() const

src/Dataflow/Engine/Controller/NetworkEditorController.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ namespace Engine {
145145
private:
146146
void printNetwork() const;
147147
Networks::ModuleHandle addModuleImpl(const std::string& moduleName);
148+
void initExecutor();
149+
ExecutionContextHandle createExecutionContext(const Networks::ExecutableLookup* lookup, Networks::ModuleFilter filter);
150+
148151
Networks::NetworkHandle theNetwork_;
149152
Networks::ModuleFactoryHandle moduleFactory_;
150153
Networks::ModuleStateFactoryHandle stateFactory_;

src/Dataflow/Engine/Scheduler/SchedulerInterfaces.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ namespace Engine {
9191
static ExecutionBounds executionBounds_;
9292
};
9393

94+
typedef boost::shared_ptr<ExecutionContext> ExecutionContextHandle;
95+
9496
template <class OrderType>
9597
class NetworkExecutor
9698
{

0 commit comments

Comments
 (0)