29 #ifndef ENGINE_SCHEDULER_DYNAMICEXECUTOR_WORKUNITPRODUCER_H
30 #define ENGINE_SCHEDULER_DYNAMICEXECUTOR_WORKUNITPRODUCER_H
37 #include <boost/foreach.hpp>
38 #include <boost/thread.hpp>
45 namespace DynamicExecutor {
52 lookup_(lookup), bounds_(bounds), network_(network), lock_(lock),
53 work_(work), doneCount_(0), shouldLog_(SCIRun::Core::Logging::Log::get().verbose())
55 log_.setVerbose(shouldLog_);
63 auto order = scheduler_.schedule(*network_);
66 std::ostringstream ostr;
67 ostr <<
"Producer received this ordering: \n" << order << std::endl;
71 auto groupIter = order.getGroup(order.minGroup());
72 BOOST_FOREACH(
const ParallelModuleExecutionOrder::ModulesByGroup::value_type& mod, groupIter)
74 auto module = network_->lookupModule(mod.second);
81 if (doneIds_.find(mod.second) != doneIds_.end())
89 doneIds_.insert(mod.second);
90 doneCount_.fetch_add(1);
93 log_ <<
Core::Logging::DEBUG_LOG <<
"Producer status: " << doneCount_ <<
" out of " << network_->nmodules() << std::endl;
107 enqueueReadyModules();
110 boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
118 return doneCount_ >= network_->nmodules();
130 static ModuleWaiting filter() {
return ModuleWaiting(); }
131 static BoostGraphParallelScheduler scheduler_;
132 const Networks::ExecutableLookup* lookup_;
133 const ExecutionBounds& bounds_;
134 const Networks::NetworkInterface* network_;
137 mutable boost::atomic<int> doneCount_;
138 mutable std::set<Networks::ModuleId> doneIds_;
Definition: ModuleInterface.h:94
virtual void enqueueReadyModules() const
Definition: WorkUnitProducer.h:58
#define SCISHARE
Definition: share.h:39
bool isDone() const
Definition: WorkUnitProducer.h:116
boost::shared_ptr< ModuleProducer > ModuleProducerPtr
Definition: WorkUnitProducer.h:143
boost::shared_ptr< ModuleWorkQueue > ModuleWorkQueuePtr
Definition: WorkQueue.h:49
Definition: SchedulerInterfaces.h:56
Definition: SchedulerInterfaces.h:62
Definition: ModuleInterface.h:92
static Log & get()
Definition: Log.cc:183
void operator()() const
Definition: WorkUnitProducer.h:100
boost::shared_ptr< ModuleInterface > ModuleHandle
Definition: NetworkFwd.h:74
ModuleProducer(const Networks::ExecutableLookup *lookup, const ExecutionBounds &bounds, const Networks::NetworkInterface *network, Core::Thread::Mutex *lock, ModuleWorkQueuePtr work)
Definition: WorkUnitProducer.h:50
Definition: WorkUnitProducer.h:47
boost::lock_guard< boost::mutex > Guard
Definition: Mutex.h:55
Definition: WorkUnitProducerInterface.h:39
Definition: NetworkInterface.h:74
Definition: NetworkInterface.h:48