Skip to content

Commit 5ac3edb

Browse files
committed
Wait on execute threads. Closes #798 and closes #659
1 parent d3a8a05 commit 5ac3edb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Dataflow/Engine/Scheduler/DynamicExecutor/WorkUnitConsumer.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ namespace DynamicExecutor {
4747
class SCISHARE ModuleConsumer : boost::noncopyable
4848
{
4949
public:
50-
explicit ModuleConsumer(ModuleWorkQueuePtr workQueue, const Networks::ExecutableLookup* lookup, ProducerInterfacePtr producer) :
51-
work_(workQueue), producer_(producer), lookup_(lookup), shouldLog_(SCIRun::Core::Logging::Log::get().verbose())
50+
explicit ModuleConsumer(ModuleWorkQueuePtr workQueue, const Networks::ExecutableLookup* lookup, ProducerInterfacePtr producer,
51+
boost::thread_group& executeThreadGroup) :
52+
work_(workQueue), producer_(producer), lookup_(lookup),
53+
executeThreadGroup_(executeThreadGroup),
54+
shouldLog_(SCIRun::Core::Logging::Log::get().verbose())
5255
{
5356
log_.setVerbose(shouldLog_);
5457
if (shouldLog_)
@@ -86,7 +89,7 @@ namespace DynamicExecutor {
8689

8790
ModuleExecutor executor(unit, lookup_, producer_);
8891
/// @todo: thread pool
89-
threads_.create_thread(boost::bind(&ModuleExecutor::run, executor));
92+
executeThreadGroup_.create_thread(boost::bind(&ModuleExecutor::run, executor));
9093
}
9194
else
9295
{
@@ -107,7 +110,7 @@ namespace DynamicExecutor {
107110
ModuleWorkQueuePtr work_;
108111
ProducerInterfacePtr producer_;
109112
const Networks::ExecutableLookup* lookup_;
110-
mutable boost::thread_group threads_;
113+
boost::thread_group& executeThreadGroup_;
111114

112115
static Core::Logging::Log& log_;
113116
bool shouldLog_;

src/Dataflow/Engine/Scheduler/DynamicMultithreadedNetworkExecutor.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,13 @@ namespace SCIRun {
5252
{
5353
public:
5454
DynamicMultithreadedNetworkExecutorImpl(const ExecutionContext& context, const NetworkInterface* network, Mutex* lock, size_t numModules) :
55+
executeThreads_(new boost::thread_group),
5556
lookup_(&context.lookup),
5657
bounds_(&context.bounds()),
5758
work_(new DynamicExecutor::ModuleWorkQueue(numModules)),
5859
producer_(new DynamicExecutor::ModuleProducer(context.addAdditionalFilter(ModuleWaitingFilter::Instance()),
5960
network, lock, work_, numModules)),
60-
consumer_(new DynamicExecutor::ModuleConsumer(work_, lookup_, producer_)),
61+
consumer_(new DynamicExecutor::ModuleConsumer(work_, lookup_, producer_, *executeThreads_)),
6162
network_(network)
6263
{
6364
}
@@ -71,8 +72,10 @@ namespace SCIRun {
7172
boost::thread produce(boost::ref(*producer_));
7273
consume.join();
7374
produce.join();
75+
executeThreads_->join_all();
7476
}
7577
private:
78+
mutable boost::shared_ptr<boost::thread_group> executeThreads_;
7679
const Networks::ExecutableLookup* lookup_;
7780
const ExecutionBounds* bounds_;
7881
DynamicExecutor::ModuleWorkQueuePtr work_;

0 commit comments

Comments
 (0)