comparison Core/MultiThreading/BagOfRunnablesBySteps.cpp @ 431:16b52fb8d034

fix by cyril paulus
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 11 May 2013 12:19:20 +0200
parents bdd72233b105
children 2d0a347e8cfc
comparison
equal deleted inserted replaced
430:f746592d8301 431:16b52fb8d034
100 bag->pimpl_->activeThreads_.erase(r.get()); 100 bag->pimpl_->activeThreads_.erase(r.get());
101 101
102 assert(t.get() != NULL); 102 assert(t.get() != NULL);
103 assert(bag->pimpl_->activeThreads_.find(r.get()) == bag->pimpl_->activeThreads_.end()); 103 assert(bag->pimpl_->activeThreads_.find(r.get()) == bag->pimpl_->activeThreads_.end());
104 104
105 t->join(); 105 if (t->joinable())
106 {
107 t->join();
108 }
109
106 bag->pimpl_->oneThreadIsJoined_.notify_one(); 110 bag->pimpl_->oneThreadIsJoined_.notify_one();
107 } 111 }
108 112
109 bag->pimpl_->oneThreadIsStopped_.wait(lock); 113 bag->pimpl_->oneThreadIsStopped_.wait(lock);
110 } 114 }
126 StopAll(); 130 StopAll();
127 131
128 // Stop the finish listener 132 // Stop the finish listener
129 pimpl_->stopFinishListener_ = true; 133 pimpl_->stopFinishListener_ = true;
130 pimpl_->oneThreadIsStopped_.notify_one(); // Awakens the listener 134 pimpl_->oneThreadIsStopped_.notify_one(); // Awakens the listener
131 pimpl_->finishListener_->join(); 135
136 if (pimpl_->finishListener_->joinable())
137 {
138 pimpl_->finishListener_->join();
139 }
132 } 140 }
133 141
134 142
135 void BagOfRunnablesBySteps::Add(IRunnableBySteps* runnable) 143 void BagOfRunnablesBySteps::Add(IRunnableBySteps* runnable)
136 { 144 {