mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-12-01 01:11:46 +00:00
Fixed potential shutdown deadlock issue
This commit is contained in:
parent
7a22148583
commit
c7399857e3
@ -33,10 +33,12 @@ void WorkerThread::WorkFunc() {
|
|||||||
started = true;
|
started = true;
|
||||||
while(active) {
|
while(active) {
|
||||||
signal.wait(mutex);
|
signal.wait(mutex);
|
||||||
if(active) work_();
|
if(active) {
|
||||||
doneMutex.lock();
|
work_();
|
||||||
done.notify_one();
|
doneMutex.lock();
|
||||||
doneMutex.unlock();
|
done.notify_one();
|
||||||
|
doneMutex.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +60,7 @@ void ThreadPool::ParallelLoop(std::function<void(int,int)> loop, int lower, int
|
|||||||
mutex.lock();
|
mutex.lock();
|
||||||
StartWorkers();
|
StartWorkers();
|
||||||
int range = upper-lower;
|
int range = upper-lower;
|
||||||
if(range >= numThreads*2) { // don't parallelize tiny loops
|
if(range >= numThreads*2) { // don't parallelize tiny loops (this could be better, maybe add optional parameter that estimates work per iteration)
|
||||||
// could do slightly better load balancing for the generic case,
|
// could do slightly better load balancing for the generic case,
|
||||||
// but doesn't matter since all our loops are power of 2
|
// but doesn't matter since all our loops are power of 2
|
||||||
int chunk = range/numThreads;
|
int chunk = range/numThreads;
|
||||||
|
Loading…
Reference in New Issue
Block a user