[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sptk-commits
Subject:    r1040 - trunk/src/utils
From:       alexey () mail ! total-knowledge ! com
Date:       2009-10-31 4:41:26
Message-ID: courier.000000004AEBBFF6.00007AA2 () mail ! total-knowledge ! com
[Download RAW message or body]

Author: alexey
Date: 2009-10-30 21:41:26 -0700 (Fri, 30 Oct 2009)
New Revision: 1040

Modified:
   trunk/src/utils/CThread.cpp
   trunk/src/utils/CThreadManager.cpp
Log:
Removing some race conditions

Modified: trunk/src/utils/CThread.cpp
===================================================================
--- trunk/src/utils/CThread.cpp	2009-10-30 23:40:16 UTC (rev 1039)
+++ trunk/src/utils/CThread.cpp	2009-10-31 04:41:26 UTC (rev 1040)
@@ -173,12 +173,12 @@
         GUARD(m_lock);
         m_running = false;
         m_terminated = true;
-
-        if (m_owner) {
-            m_owner->registerTerminated(this);
-            m_owner = NULL;
-        }
     }
+    
+    if (m_owner) {
+	m_owner->registerTerminated(this);
+	m_owner = NULL;
+    }
 
     destroyThread();
 }

Modified: trunk/src/utils/CThreadManager.cpp
===================================================================
--- trunk/src/utils/CThreadManager.cpp	2009-10-30 23:40:16 UTC (rev 1039)
+++ trunk/src/utils/CThreadManager.cpp	2009-10-31 04:41:26 UTC (rev 1040)
@@ -76,9 +76,11 @@
     CThread* terminatedThread;
 
     while (!CThread::terminated()) {
-        if (m_terminatedThreads.pop(terminatedThread,1000)) {
+        if (m_terminatedThreads.pop(terminatedThread, 1000)) {
             if (m_log)
                 *m_log << "Thread " << terminatedThread->name() << " deleted by thread manager" << endl;
+            while (terminatedThread->running())
+                msleep(100);
             delete terminatedThread;
         }
     }

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic