@@ -64,7 +64,6 @@ NetworkEditorController::NetworkEditorController(ModuleFactoryHandle mf, ModuleS
6464 reexFactory_(reex),
6565 executorFactory_(executorFactory),
6666 serializationManager_(nesm),
67- executionManager_(currentExecutor_), // TODO: pass in factory instead
6867 signalSwitch_(true )
6968{
7069 dynamicPortManager_.reset (new DynamicPortManager (connectionAdded_, connectionRemoved_, this ));
@@ -77,7 +76,7 @@ NetworkEditorController::NetworkEditorController(ModuleFactoryHandle mf, ModuleS
7776}
7877
7978NetworkEditorController::NetworkEditorController (SCIRun::Dataflow::Networks::NetworkHandle network, ExecutionStrategyFactoryHandle executorFactory, NetworkEditorSerializationManager* nesm)
80- : theNetwork_(network), executorFactory_(executorFactory), serializationManager_(nesm), executionManager_(currentExecutor_) // TODO: pass in factory instead
79+ : theNetwork_(network), executorFactory_(executorFactory), serializationManager_(nesm)
8180{
8281}
8382
@@ -352,10 +351,7 @@ void NetworkEditorController::executeModule(const ModuleHandle& module, const Ex
352351
353352void NetworkEditorController::initExecutor ()
354353{
355- if (!currentExecutor_)
356- {
357- currentExecutor_ = executorFactory_->createDefault ();
358- }
354+ executionManager_.initExecutor (executorFactory_);
359355}
360356
361357ExecutionContextHandle NetworkEditorController::createExecutionContext (const ExecutableLookup* lookup, ModuleFilter filter)
@@ -372,46 +368,6 @@ void NetworkEditorController::executeGeneric(const ExecutableLookup* lookup, Mod
372368 executionManager_.enqueueContext (context);
373369}
374370
375- ExecutionQueueManager::ExecutionQueueManager (ExecutionStrategyHandle& currentExecutor) : contexts_(2 ), currentExecutor_(currentExecutor),
376- executionLaunchThread_([this ]() {executeTopContext (); } ),
377- executionMutex_ (" executionQueue" ),
378- somethingToExecute_(" executionQueue" )
379- {
380- }
381-
382- void ExecutionQueueManager::enqueueContext (ExecutionContextHandle context)
383- {
384- bool contextReady = false ;
385- {
386- Guard g (executionMutex_.get ());
387- contextReady = contexts_.push (context);
388- }
389- if (contextReady)
390- {
391- contextCount_.fetch_add (1 );
392- // std::cout << "ctx queued" << std::endl;
393- somethingToExecute_.conditionBroadcast ();
394- }
395- else
396- {
397- // std::cout << "ctx queue is full" << std::endl;
398- }
399- }
400-
401- void ExecutionQueueManager::executeTopContext ()
402- {
403- while (true )
404- {
405- UniqueLock lock (executionMutex_.get ());
406- while (0 == contextCount_)
407- {
408- somethingToExecute_.wait (lock);
409- }
410- contexts_.consume_one ([&](ExecutionContextHandle ctx) { currentExecutor_->execute (*ctx); });
411- contextCount_.fetch_sub (1 );
412- }
413- }
414-
415371NetworkHandle NetworkEditorController::getNetwork () const
416372{
417373 return theNetwork_;
@@ -430,7 +386,7 @@ NetworkGlobalSettings& NetworkEditorController::getSettings()
430386
431387void NetworkEditorController::setExecutorType (int type)
432388{
433- currentExecutor_ = executorFactory_->create ((ExecutionStrategy::Type)type);
389+ executionManager_. setExecutionStrategy ( executorFactory_->create ((ExecutionStrategy::Type)type) );
434390}
435391
436392const ModuleDescriptionMap& NetworkEditorController::getAllAvailableModuleDescriptions () const
0 commit comments