diff options
author | Vincent-Michael <Vincent_Michael@gmx.de> | 2014-08-23 16:41:54 +0200 |
---|---|---|
committer | Vincent-Michael <Vincent_Michael@gmx.de> | 2014-08-23 16:41:54 +0200 |
commit | 4a29c73403c4dc713a8a31cb96289adff2b910c1 (patch) | |
tree | de0c6b191031bac7fb2764edb2a81382a331f81c /dep/g3dlite/source/ThreadSet.cpp | |
parent | b90329d63acaecb1f074dd2b303561baa9f639a2 (diff) | |
parent | 1255434882777053bca06656786abc1a598deda9 (diff) |
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
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()) { |