[openrtm-commit:00651] r2296 - trunk/OpenRTM-aist/src/lib/rtm

openrtm @ openrtm.org openrtm @ openrtm.org
2012年 2月 4日 (土) 00:55:49 JST


Author: n-ando
Date: 2012-02-04 00:55:49 +0900 (Sat, 04 Feb 2012)
New Revision: 2296

Modified:
   trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.cpp
   trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.h
Log:
[compat,doc/impl,bugfix] setOwner()'s bug was fixed. Some mutex guards have been added. refs #2342

Modified: trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.cpp	2012-02-03 09:56:22 UTC (rev 2295)
+++ trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.cpp	2012-02-03 15:55:49 UTC (rev 2296)
@@ -16,6 +16,7 @@
  *
  */
 
+#include <assert.h>
 #include <rtm/ExecutionContextProfile.h>
 #include <rtm/CORBA_SeqUtil.h>
 #include <rtm/NVUtil.h>
@@ -78,6 +79,7 @@
   setObjRef(RTC::ExecutionContextService_ptr ec_ptr)
   {
     RTC_TRACE(("setObjRef()"));
+    assert(!CORBA::is_nil(ec_ptr));
     Guard guard(m_profileMutex);
     m_ref = RTC::ExecutionContextService::_duplicate(ec_ptr);
   }
@@ -106,7 +108,7 @@
    */
   RTC::ReturnCode_t ExecutionContextProfile::setRate(double rate)
   {
-    RTC_TRACE(("set_rate(%f)", rate));
+    RTC_TRACE(("setRate(%f)", rate));
     if (rate < 0.0) { return RTC::BAD_PARAMETER; }
 
     Guard guard(m_profileMutex);
@@ -114,6 +116,7 @@
     m_period = coil::TimeValue(1.0/rate);
     return RTC::RTC_OK;
   }
+
   RTC::ReturnCode_t ExecutionContextProfile::setPeriod(double period)
   {
     RTC_TRACE(("setPeriod(%f [sec])", period));
@@ -124,6 +127,7 @@
     m_period = coil::TimeValue(period);
     return RTC::RTC_OK;
   }
+
   RTC::ReturnCode_t ExecutionContextProfile::setPeriod(coil::TimeValue period)
   {
     RTC_TRACE(("setPeriod(%f [sec])", (double)period));
@@ -144,14 +148,12 @@
    */
   CORBA::Double ExecutionContextProfile::getRate() const
   {
-    RTC_TRACE(("get_rate()"));
     Guard guard(m_profileMutex);
     return m_profile.rate;
   }
 
   coil::TimeValue ExecutionContextProfile::getPeriod() const
   {
-    RTC_TRACE(("getPeriod()"));
     Guard guard(m_profileMutex);
     return m_period;
   }
@@ -203,6 +205,7 @@
    */
   RTC::ExecutionKind ExecutionContextProfile::getKind(void) const
   {
+    Guard guard(m_profileMutex);
     RTC_TRACE(("%s = getKind()", getKindString(m_profile.kind)));
     return m_profile.kind;
   }
@@ -218,19 +221,15 @@
   setOwner(RTC::LightweightRTObject_ptr comp)
   {
     RTC_TRACE(("setOwner()"));
-    if (CORBA::is_nil(comp))
-      {
-        RTC_ERROR(("nil reference is given."));
-        return RTC::BAD_PARAMETER;
-      }
-    RTC::RTObject_var rtobj;
-    rtobj = RTC::RTObject::_narrow(comp);
+    assert(!CORBA::is_nil(comp));
+    RTC::RTObject_var rtobj = RTC::RTObject::_narrow(comp);
     if (CORBA::is_nil(rtobj))
       {
         RTC_ERROR(("Narrowing failed."));
-        return RTC::RTC_ERROR;
+        return RTC::BAD_PARAMETER;
       }
-    m_profile.owner = RTC::RTObject::_duplicate(m_profile.owner);
+    Guard guard(m_profileMutex);
+    m_profile.owner = RTC::RTObject::_duplicate(rtobj);
     return RTC::RTC_OK;
   }
 
@@ -244,6 +243,7 @@
   const RTC::RTObject_ptr ExecutionContextProfile::getOwner() const
   {
     RTC_TRACE(("getOwner()"));
+    Guard guard(m_profileMutex);
     return RTC::RTObject::_duplicate(m_profile.owner);
   }
 
@@ -269,6 +269,7 @@
         RTC_ERROR(("Narrowing was failed."));
         return RTC::RTC_ERROR;
       }
+    Guard guard(m_profileMutex);
     CORBA_SeqUtil::push_back(m_profile.participants, rtobj._retn());
     return RTC::RTC_OK;
   }

Modified: trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.h	2012-02-03 09:56:22 UTC (rev 2295)
+++ trunk/OpenRTM-aist/src/lib/rtm/ExecutionContextProfile.h	2012-02-03 15:55:49 UTC (rev 2296)
@@ -95,20 +95,24 @@
 
     /*!
      * @if jp
-     * @brief CORBA オブジェクト参照の取得
+     * @brief CORBA オブジェクト参照のセット
      *
-     * 本オブジェクトの ExecutioncontextService としての CORBA オブジェ
-     * クト参照を取得する。
+     * ExecutioncontextService の CORBA オブジェクト参照をセットする。
+     * セットされると、それまでセットされていたオブジェクト参照は
+     * releaseされる。セットするオブジェクト参照は有効な参照でなければ
+     * ならない。
      *
-     * @return CORBA オブジェクト参照
+     * @param ec_ptr ExecutionContextServiceのCORBAオブジェクト参照
      *
      * @else
-     * @brief Get the reference to the CORBA object
+     * @brief Setting a CORBA object reference
      *
-     * Get the reference to the CORBA object as
-     * ExecutioncontextService of this object.
+     * This operation sets a object reference to
+     * ExecutionContextService.  After setting a new object reference,
+     * old reference is released.  The object reference have to be
+     * valid reference.
      *
-     * @return The reference to CORBA object
+     * @param ec_ptr A CORBA object reference of ExecutionContextService
      *
      * @endif
      */
@@ -370,7 +374,11 @@
      * @if jp
      * @brief RTコンポーネントの参加者リストを取得する
      *
-     * 現在登録されている参加者RTCのリストを取得する。
+     * 現在登録されている参加者RTCのリストを取得する。この関数はコンポー
+     * ネントリストのメンバ変数への参照を返すので、リスト使用前に
+     * ExecutionContextProfile::lock() でロックし、リスト使用後は
+     * ExecutionContextProfile::unlock() でロックを開放しなければならな
+     * い。
      *
      * @return 参加者RTCのリスト
      *
@@ -378,7 +386,12 @@
      *
      * @brief Getting participant RTC list
      *
-     * This function returns a list of participant RTC of the execution context.
+     * This function returns a list of participant RTC of the
+     * execution context.  Since the function returns a reference to
+     * the member variable of component list, user have to lock by
+     * ExecutionContextProfile::lock() before using the list, and user
+     * also have to release the unlock by
+     * ExecutionContextProfile::unlock().
      *
      * @return Participants RTC list
      *



openrtm-commit メーリングリストの案内