From 2551b705a9692c2ba52d129814fa669d5c58f56d Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 3 Apr 2003 02:36:51 +0000 Subject: "" svn path=/trunk/; revision=532 --- externals/grill/flext/source/flthr.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'externals/grill/flext/source/flthr.cpp') 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); } -- cgit v1.2.1