Forgot loop sequentialization

This commit is contained in:
Peter Thoman committed 2013-05-01 13:20:25 +02:00
1 parent 0fcf809d37
commit f0f0fd2b75
2 files changed
+4 -2

No files matched your search

+2
View File
@@ -55,6 +55,7 @@ void ThreadPool::StartWorkers() {
}
void ThreadPool::ParallelLoop(std::function<void(int,int)> loop, int lower, int upper) {
mutex.lock();
StartWorkers();
int range = upper-lower;
if(range >= numThreads*2) { // don't parallelize tiny loops
@@ -70,5 +71,6 @@ void ThreadPool::ParallelLoop(std::function<void(int,int)> loop, int lower, int
} else {
loop(lower, upper);
}
mutex.unlock();
}
+2 -2
View File
@@ -34,8 +34,8 @@ private:
};
// A thread pool manages a set of worker threads, and allows the execution of parallel loops on them
// individual parallel loops are sequentialized, which should not be a problem as they should each
// use the entire system
// individual parallel loops are fully sequentialized to simplify synchronization, which should not
// be a problem as they should each use the entire system
class ThreadPool {
public:
ThreadPool(int numThreads);