aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-04-03 02:36:51 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-04-03 02:36:51 +0000
commit2551b705a9692c2ba52d129814fa669d5c58f56d (patch)
tree74b12103e67e0ac7741e8ad7c92e31a9fe670eaa /externals/grill/flext/source
parentf1696e650bfba449ec75a5e83ea04a821c32dc3d (diff)
""
svn path=/trunk/; revision=532
Diffstat (limited to 'externals/grill/flext/source')
-rw-r--r--externals/grill/flext/source/flthr.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/externals/grill/flext/source/flthr.cpp b/externals/grill/flext/source/flthr.cpp
index d2430041..d15e33d0 100644
--- a/externals/grill/flext/source/flthr.cpp
+++ b/externals/grill/flext/source/flthr.cpp
@@ -69,14 +69,14 @@ bool flext::StartHelper()
// now we have to wait for thread helper to initialize
while(!thrhelpid || !thrhelpcond) Sleep(0.001);
- // we are reading for threading now!
+ // we are ready for threading now!
}
return ok;
}
#if 0
/*! \brief Stop helper thread
- \note not called!
+ \note Never called!
*/
bool flext::StopHelper()
{
@@ -85,6 +85,7 @@ bool flext::StopHelper()
}
#endif
+
//! Static helper thread function
void flext::ThrHelper(void *)
{
@@ -242,7 +243,7 @@ bool flext_base::StopThreads()
{
thr_entry *t;
- // signal termination
+ // signal termination for all object's threads
tlmutex.Lock();
for(t = thrhead; t; t = t->nxt) {
if(t->This() == this) t->shouldexit = true;
@@ -254,12 +255,16 @@ bool flext_base::StopThreads()
// wait for thread termination (1 second max.)
int cnt;
for(int wi = 0; wi < 100; ++wi) {
- cnt = 0;
+ // lock and count this object's threads
tlmutex.Lock();
- for(t = thrhead; t; t = t->nxt)
+ for(cnt = 0,t = thrhead; t; t = t->nxt)
if(t->This() == this) ++cnt;
tlmutex.Unlock();
+
+ // if no threads are remaining, we are done
if(!cnt) break;
+
+ // Wait
Sleep(0.01f);
}