etch-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vei...@apache.org
Subject svn commit: r1578886 - in /etch/trunk/binding-cpp/runtime: include/support/EtchPlainMailbox.h include/transport/EtchPlainMailboxManager.h src/main/support/EtchPlainMailbox.cpp src/main/transport/EtchPlainMailboxManager.cpp
Date Tue, 18 Mar 2014 13:43:43 GMT
Author: veithm
Date: Tue Mar 18 13:43:43 2014
New Revision: 1578886

URL: http://svn.apache.org/r1578886
Log:
Renaming mutexes in EtchPlainMailbox and EtchPlainMailboxManager

Till now the mutexes in both files were named simple mMutex.
Now the mutexes got more meaningful names which tell what they
do protect.

Change-Id: I769744e2342714d4536b5f89ef6bfcfdc13456ee

Modified:
    etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h
    etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h
    etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp
    etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp

Modified: etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h
URL: http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h?rev=1578886&r1=1578885&r2=1578886&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h (original)
+++ etch/trunk/binding-cpp/runtime/include/support/EtchPlainMailbox.h Tue Mar 18 13:43:43
2014
@@ -135,7 +135,7 @@ private:
   EtchLong mMessageId;
   capu::bool_t mAlarmSet;
   EtchCircularQueue mQueue;
-  capu::Mutex mMutex;
+  capu::Mutex mQueueMutex;
 
   void fireNotify();
 };

Modified: etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h
URL: http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h?rev=1578886&r1=1578885&r2=1578886&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h (original)
+++ etch/trunk/binding-cpp/runtime/include/transport/EtchPlainMailboxManager.h Tue Mar 18
13:43:43 2014
@@ -110,7 +110,7 @@ private:
   EtchTransportMessage* mTransport;
   capu::bool_t mUp;
   EtchHashTable<EtchLong, capu::SmartPointer<EtchMailbox> > mMailboxes;
-  capu::Mutex mMutex;
+  capu::Mutex mMailboxesMutex;
   EtchIdGenerator mIdGen;
 };
 

Modified: etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp
URL: http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp?rev=1578886&r1=1578885&r2=1578886&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp (original)
+++ etch/trunk/binding-cpp/runtime/src/main/support/EtchPlainMailbox.cpp Tue Mar 18 13:43:43
2014
@@ -22,12 +22,14 @@ EtchPlainMailbox::EtchPlainMailbox(EtchM
 }
 
 EtchPlainMailbox::~EtchPlainMailbox() {
+  mQueueMutex.lock();
   while (!mQueue.isEmpty()) {
     EtchMailbox::EtchElement* element = NULL;
     if(ETCH_OK == mQueue.get(&element)) {
       delete element;
     }
   }
+  mQueueMutex.unlock();
 }
 
 EtchMailboxManager* EtchPlainMailbox::getMailboxManager() {
@@ -42,9 +44,9 @@ status_t EtchPlainMailbox::message(capu:
   status_t status;
   EtchMailbox::EtchElement* element = new EtchMailbox::EtchElement(sender, msg);
 
-  mMutex.lock();
+  mQueueMutex.lock();
   status = mQueue.put(element, -1);
-  mMutex.unlock();
+  mQueueMutex.unlock();
 
   if(status == ETCH_OK) {
      fireNotify();
@@ -62,7 +64,7 @@ void EtchPlainMailbox::fireNotify() {
   EtchObject* s;
   capu::bool_t c;
 
-  mMutex.lock();
+  mQueueMutex.lock();
   n = mNotify;
   s = mState;
   c = mQueue.isClosed();
@@ -70,13 +72,13 @@ void EtchPlainMailbox::fireNotify() {
   if (n != NULL) {
     n->mailboxStatus(this, s, c);
   }
-  mMutex.unlock();
+  mQueueMutex.unlock();
 }
 
 status_t EtchPlainMailbox::read(EtchMailbox::EtchElement*& result) {
-  mMutex.lock();
+  mQueueMutex.lock();
   status_t status = mQueue.get(&result);
-  mMutex.unlock();
+  mQueueMutex.unlock();
   if(ETCH_OK == status) {
     return ETCH_OK;
   }
@@ -85,9 +87,9 @@ status_t EtchPlainMailbox::read(EtchMail
 }
 
 status_t EtchPlainMailbox::read(EtchMailbox::EtchElement *& result, capu::int32_t maxDelay)
{
-  mMutex.lock();
+  mQueueMutex.lock();
   status_t status = mQueue.get(&result, maxDelay);
-  mMutex.unlock();
+  mQueueMutex.unlock();
   if(status == ETCH_OK) {
     return ETCH_OK;
   }
@@ -96,15 +98,15 @@ status_t EtchPlainMailbox::read(EtchMail
 
 status_t EtchPlainMailbox::closeDelivery(capu::bool_t withNotification) {
 
-  mMutex.lock();
+  mQueueMutex.lock();
   if(mQueue.isClosed()) {
-    mMutex.unlock();
+    mQueueMutex.unlock();
     return ETCH_EINVAL;
   }
 
   mMailboxManager->unregisterMailbox(getMessageId());
   mQueue.close();
-  mMutex.unlock();
+  mQueueMutex.unlock();
 
   if (withNotification) {
     fireNotify();
@@ -136,10 +138,10 @@ status_t EtchPlainMailbox::registerNotif
 
   capu::bool_t isNotEmptyOrIsClosed;
 
-  mMutex.lock();
+  mQueueMutex.lock();
 
   if(mNotify != NULL) {
-    mMutex.unlock();
+    mQueueMutex.unlock();
     return ETCH_EINVAL;
   }
 
@@ -148,7 +150,7 @@ status_t EtchPlainMailbox::registerNotif
 
   isNotEmptyOrIsClosed = !mQueue.isEmpty() || mQueue.isClosed();
 
-  mMutex.unlock();
+  mQueueMutex.unlock();
 
   if(isNotEmptyOrIsClosed) {
     fireNotify();
@@ -167,32 +169,38 @@ status_t EtchPlainMailbox::unregisterNot
     return ETCH_OK;
   }
 
-  mMutex.lock();
+  mQueueMutex.lock();
 
   if(mNotify !=  notify) {
-    mMutex.unlock();
+    mQueueMutex.unlock();
     return ETCH_EINVAL;
   }
 
   mNotify = NULL;
   mState = NULL;
 
-  mMutex.unlock();
+  mQueueMutex.unlock();
 
   return ETCH_OK;
 }
 
 capu::bool_t EtchPlainMailbox::isEmpty() {
+  mQueueMutex.lock();
   capu::bool_t res = mQueue.isEmpty();
+  mQueueMutex.unlock();
   return res;
 }
 
 capu::bool_t EtchPlainMailbox::isClosed() {
+  mQueueMutex.lock();
   capu::bool_t res = mQueue.isClosed();
+  mQueueMutex.unlock();
   return res;
 }
 
 capu::bool_t EtchPlainMailbox::isFull() {
+  mQueueMutex.lock();
   capu::bool_t res = mQueue.isFull();
+  mQueueMutex.unlock();
   return res;
 }

Modified: etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp
URL: http://svn.apache.org/viewvc/etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp?rev=1578886&r1=1578885&r2=1578886&view=diff
==============================================================================
--- etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp (original)
+++ etch/trunk/binding-cpp/runtime/src/main/transport/EtchPlainMailboxManager.cpp Tue Mar
18 13:43:43 2014
@@ -26,7 +26,7 @@ EtchPlainMailboxManager::EtchPlainMailbo
 }
 
 EtchPlainMailboxManager::~EtchPlainMailboxManager() {
-  mMutex.lock();
+  mMailboxesMutex.lock();
 
   EtchHashTable<EtchLong, capu::SmartPointer<EtchMailbox> >::Iterator it = mMailboxes.begin();
   EtchHashTable<EtchLong, capu::SmartPointer<EtchMailbox> >::HashTableEntry entry;
@@ -36,7 +36,7 @@ EtchPlainMailboxManager::~EtchPlainMailb
     entry.value->closeDelivery();
   }
 
-  mMutex.unlock();
+  mMailboxesMutex.unlock();
 }
 
 EtchTransportMessage* EtchPlainMailboxManager::getTransport() {
@@ -70,9 +70,9 @@ status_t EtchPlainMailboxManager::regist
 
 status_t EtchPlainMailboxManager::unregisterMailbox(EtchLong mailboxId) {
   capu::SmartPointer<EtchMailbox> tmp = NULL;
-  mMutex.lock();
+  mMailboxesMutex.lock();
   mMailboxes.remove(mailboxId, &tmp);
-  mMutex.unlock();
+  mMailboxesMutex.unlock();
   return ETCH_OK;
 }
 
@@ -86,13 +86,13 @@ status_t EtchPlainMailboxManager::sessio
   if(msg->getInReplyToMessageId(msgid) == ETCH_OK) {
     capu::SmartPointer<EtchMailbox> mb = NULL;
     ETCH_LOG_DEBUG(mRuntime->getLogger(), mRuntime->getLogger().getMailboxContext(),
"A message has been received as answer to message identified by msgid " << msgid);
-	mMutex.lock();
+	mMailboxesMutex.lock();
     if (getMailbox(msgid, mb) != ETCH_OK) {
-	  mMutex.unlock();
+	  mMailboxesMutex.unlock();
       ETCH_LOG_ERROR(mRuntime->getLogger(), mRuntime->getLogger().getMailboxContext(),
"Mailbox for Message with msgid " << msgid << "has already been closed and removed.
Dropping message.");
       return ETCH_ERROR;
     }
-    mMutex.unlock();
+    mMailboxesMutex.unlock();
     ETCH_LOG_DEBUG(mRuntime->getLogger(), mRuntime->getLogger().getMailboxContext(),
"Message has been sent to respective mailbox");
 	status_t status = mb->message(sender, msg);
 	
@@ -122,21 +122,22 @@ status_t EtchPlainMailboxManager::transp
 
   ETCH_LOG_DEBUG(mRuntime->getLogger(), mRuntime->getLogger().getMailboxContext(),
"A mailbox has been created for msgid " << msgid);
   capu::SmartPointer<EtchMailbox> mb = new EtchPlainMailbox(this, msgid);
-  mMutex.lock();
+
+  mMailboxesMutex.lock();
   if (registerMailbox(mb) != ETCH_OK) {
     ETCH_LOG_ERROR(mRuntime->getLogger(), mRuntime->getLogger().getMailboxContext(),
"Mailbox registration failed");
-    mMutex.unlock();
+    mMailboxesMutex.unlock();
     return ETCH_ERROR;
   }
 
   ETCH_LOG_DEBUG(mRuntime->getLogger(), mRuntime->getLogger().getMailboxContext(),
"Message sending to Messagizer and registering a respective mailbox");
   if (mTransport->transportMessage(recipient, msg) == ETCH_OK) {
     result = mb;
-    mMutex.unlock();
+    mMailboxesMutex.unlock();
     return ETCH_OK;
   } else {
     mb->closeDelivery();
-    mMutex.unlock();
+    mMailboxesMutex.unlock();
     return ETCH_ERROR;
   }
 }
@@ -178,7 +179,7 @@ status_t EtchPlainMailboxManager::sessio
 }
 
 status_t EtchPlainMailboxManager::sessionNotify(capu::SmartPointer<EtchObject> event)
{
-  mMutex.lock();
+  mMailboxesMutex.lock();
   if (event->equals(&EtchSession::UP())) {
     mUp = true;
     ETCH_LOG_TRACE(mRuntime->getLogger(), mRuntime->getLogger().getMailboxContext(),
"Connection is up");
@@ -192,7 +193,7 @@ status_t EtchPlainMailboxManager::sessio
     }
     ETCH_LOG_TRACE(mRuntime->getLogger(), mRuntime->getLogger().getMailboxContext(),
"Connection is down");
   }
-  mMutex.unlock();
+  mMailboxesMutex.unlock();
 
   status_t status;
   if(mSession != NULL) {



Mime
View raw message