[asterisk-scf-commits] asterisk-scf/release/ice-util-cpp.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Fri Sep 30 14:04:24 CDT 2011


branch "master" has been updated
       via  80921541054ae118a5d491f310c15599b9fb3d6d (commit)
      from  a69578535af992b0e3a082832c3f90a934c7bc58 (commit)

Summary of changes:
 src/PJLib/ThreadHook.cpp |   46 ++++++++++++++++++++++++----------------------
 1 files changed, 24 insertions(+), 22 deletions(-)


- Log -----------------------------------------------------------------
commit 80921541054ae118a5d491f310c15599b9fb3d6d
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Fri Sep 30 14:03:39 2011 -0500

    Reorganize code in functions to better conform to coding guidelines.
    
    (This was requested in CR-ASTSCF-168, but forgotten during the merge of
    the reviewed branch.)

diff --git a/src/PJLib/ThreadHook.cpp b/src/PJLib/ThreadHook.cpp
index 93a7bab..4467acb 100644
--- a/src/PJLib/ThreadHook.cpp
+++ b/src/PJLib/ThreadHook.cpp
@@ -34,22 +34,24 @@ ThreadHook::ThreadHook(const std::string& threadGroup) : mThreadGroup(threadGrou
 {
     boost::lock_guard<boost::mutex> lock(mInitLock);
 
-    if(!mpjInitialized)
+    if(mpjInitialized)
     {
-	pj_status_t status = pj_init();
-	if(status != PJ_SUCCESS)
-	{
-	    throw PJLibInitializationFailed(status);
-	}
-
-	status = pjlib_util_init();
-	if(status != PJ_SUCCESS)
-	{
-	    throw PJLibUtilInitializationFailed(status);
-	}
-
-	mpjInitialized = true;
+	return;
     }
+
+    pj_status_t status = pj_init();
+    if(status != PJ_SUCCESS)
+    {
+	throw PJLibInitializationFailed(status);
+    }
+
+    status = pjlib_util_init();
+    if(status != PJ_SUCCESS)
+    {
+	throw PJLibUtilInitializationFailed(status);
+    }
+
+    mpjInitialized = true;
 }
 
 /**
@@ -66,11 +68,9 @@ void ThreadHook::start()
     {
         throw ThreadRegistrationFailed(status);
     }
-    else
-    {
-        boost::lock_guard<boost::mutex> lock(mMapLock);
-        mpjThreads.insert(std::make_pair(thread, wrapper));
-    }
+
+    boost::lock_guard<boost::mutex> lock(mMapLock);
+    mpjThreads.insert(std::make_pair(thread, wrapper));
 }
 
 /**
@@ -78,11 +78,13 @@ void ThreadHook::start()
  */
 void ThreadHook::stop()
 {
-    if (pj_thread_is_registered())
+    if (!pj_thread_is_registered())
     {
-        boost::lock_guard<boost::mutex> lock(mMapLock);
-        mpjThreads.erase(pj_thread_this());
+	return;
     }
+
+    boost::lock_guard<boost::mutex> lock(mMapLock);
+    mpjThreads.erase(pj_thread_this());
 }
 
 } // end namespace PJLib

-----------------------------------------------------------------------


-- 
asterisk-scf/release/ice-util-cpp.git



More information about the asterisk-scf-commits mailing list