diff options
author | jackpoz <giacomopoz@gmail.com> | 2014-08-22 16:58:23 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2014-08-22 21:00:56 +0200 |
commit | 5e8277e923c5545a15bae7c740ab6afaa597a59f (patch) | |
tree | 4cf5212c080588a7e868ee60134fc7fff51e400a /dep/g3dlite/source/ThreadSet.cpp | |
parent | a63aa858dcb400eafb97eed1f590e34c27d934a4 (diff) |
Core/Dependencies: Update G3D to v9.0 r4036
Diffstat (limited to 'dep/g3dlite/source/ThreadSet.cpp')
-rw-r--r-- | dep/g3dlite/source/ThreadSet.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/dep/g3dlite/source/ThreadSet.cpp b/dep/g3dlite/source/ThreadSet.cpp index ee3895fe9de..df6fd4d4721 100644 --- a/dep/g3dlite/source/ThreadSet.cpp +++ b/dep/g3dlite/source/ThreadSet.cpp @@ -1,4 +1,5 @@ #include "G3D/ThreadSet.h" +#include "G3D/GThread.h" namespace G3D { @@ -25,7 +26,7 @@ int ThreadSet::numStarted() const { } -void ThreadSet::start(GThread::SpawnBehavior lastBehavior) const { +void ThreadSet::start(SpawnBehavior lastBehavior) const { ThreadSet* me = const_cast<ThreadSet*>(this); Array<GThreadRef> unstarted; @@ -38,20 +39,22 @@ void ThreadSet::start(GThread::SpawnBehavior lastBehavior) const { } int last = unstarted.size(); - if (lastBehavior == GThread::USE_CURRENT_THREAD) { + if (lastBehavior == USE_CURRENT_THREAD) { // Save the last unstarted for the current thread --last; } + // Start all threads for (int i = 0; i < last; ++i) { - unstarted[i]->start(GThread::USE_NEW_THREAD); + unstarted[i]->start(USE_NEW_THREAD); } me->m_lock.unlock(); // Start the last one on my thread - if ((unstarted.size() > 0) && (lastBehavior == GThread::USE_CURRENT_THREAD)) { - unstarted.last()->start(GThread::USE_CURRENT_THREAD); + if ((unstarted.size() > 0) && (lastBehavior == USE_CURRENT_THREAD)) { + unstarted.last()->start(USE_CURRENT_THREAD); + debugAssert(unstarted.last()->completed()); } } @@ -70,6 +73,7 @@ void ThreadSet::terminate() const { void ThreadSet::waitForCompletion() const { ThreadSet* me = const_cast<ThreadSet*>(this); + me->m_lock.lock(); for (int i = 0; i < m_thread.size(); ++i) { if (m_thread[i]->started()) { |