Skip to content

Commit d3a8a05

Browse files
committed
Use thread group
1 parent 36b294f commit d3a8a05

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/Core/Thread/Parallel.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ using namespace SCIRun::Core::Thread;
3636
void Parallel::RunTasks(IndexedTask task, int numProcs)
3737
{
3838
boost::thread_group threads;
39-
39+
4040
for (int i = 0; i < numProcs; ++i)
4141
{
4242
threads.create_thread(boost::bind(task, i));

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <Dataflow/Engine/Scheduler/DynamicExecutor/WorkUnitExecutor.h>
3535
#include <Dataflow/Network/NetworkInterface.h>
3636
#include <Core/Logging/Log.h>
37-
#include <boost/thread.hpp>
37+
#include <boost/thread/thread.hpp>
3838

3939
#include <Dataflow/Engine/Scheduler/share.h>
4040

@@ -86,7 +86,7 @@ namespace DynamicExecutor {
8686

8787
ModuleExecutor executor(unit, lookup_, producer_);
8888
/// @todo: thread pool
89-
boost::thread t(boost::bind(&ModuleExecutor::run, executor));
89+
threads_.create_thread(boost::bind(&ModuleExecutor::run, executor));
9090
}
9191
else
9292
{
@@ -107,6 +107,8 @@ namespace DynamicExecutor {
107107
ModuleWorkQueuePtr work_;
108108
ProducerInterfacePtr producer_;
109109
const Networks::ExecutableLookup* lookup_;
110+
mutable boost::thread_group threads_;
111+
110112
static Core::Logging::Log& log_;
111113
bool shouldLog_;
112114
};
@@ -116,4 +118,4 @@ namespace DynamicExecutor {
116118
}}
117119
}}
118120

119-
#endif
121+
#endif

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ namespace SCIRun {
4848
{
4949
public:
5050
ModuleProducer(const Networks::ModuleFilter& filter,
51-
const Networks::ExecutableLookup* lookup, const ExecutionBounds& bounds,
5251
const Networks::NetworkInterface* network, Core::Thread::Mutex* lock, ModuleWorkQueuePtr work, size_t numModules) :
53-
scheduler_(filter),
54-
lookup_(lookup), bounds_(bounds), network_(network), lock_(lock),
52+
scheduler_(filter), network_(network), lock_(lock),
5553
work_(work), doneCount_(0), shouldLog_(SCIRun::Core::Logging::Log::get().verbose()), numModules_(numModules)
5654
{
5755
log_.setVerbose(shouldLog_);
@@ -79,7 +77,7 @@ namespace SCIRun {
7977
{
8078
if (shouldLog_)
8179
log_ << Core::Logging::DEBUG_LOG << "Producer pushing module " << mod.second << std::endl;
82-
80+
8381
if (doneIds_.find(mod.second) != doneIds_.end())
8482
{
8583
if (shouldLog_)
@@ -113,14 +111,12 @@ namespace SCIRun {
113111
log_ << Core::Logging::DEBUG_LOG << "Producer is done." << std::endl;
114112
}
115113

116-
bool isDone() const
114+
bool isDone() const
117115
{
118116
return doneCount_ >= numModules_;
119117
}
120118
private:
121119
BoostGraphParallelScheduler scheduler_;
122-
const Networks::ExecutableLookup* lookup_;
123-
const ExecutionBounds& bounds_;
124120
const Networks::NetworkInterface* network_;
125121
Core::Thread::Mutex* lock_;
126122
ModuleWorkQueuePtr work_;
@@ -137,4 +133,4 @@ namespace SCIRun {
137133

138134
}}
139135

140-
#endif
136+
#endif

src/Dataflow/Engine/Scheduler/DynamicMultithreadedNetworkExecutor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace SCIRun {
5656
bounds_(&context.bounds()),
5757
work_(new DynamicExecutor::ModuleWorkQueue(numModules)),
5858
producer_(new DynamicExecutor::ModuleProducer(context.addAdditionalFilter(ModuleWaitingFilter::Instance()),
59-
lookup_, context.bounds(), network, lock, work_, numModules)),
59+
network, lock, work_, numModules)),
6060
consumer_(new DynamicExecutor::ModuleConsumer(work_, lookup_, producer_)),
6161
network_(network)
6262
{

0 commit comments

Comments
 (0)