Removed unnecessary mutex lock 88/29788/2
authorNick Holland <nick.holland@partner.samsung.com>
Tue, 4 Nov 2014 10:14:05 +0000 (10:14 +0000)
committerNick Holland <nick.holland@partner.samsung.com>
Tue, 4 Nov 2014 11:50:07 +0000 (11:50 +0000)
Profiler flagged this function up.
For dali-demo it gets called over 2500 times on start-up ( by reserve message
slot).
As it's only ever called from a single thread the mutex is not needed.

Change-Id: I3e6784aa62d118360244891684c4e09d0896b3ef

adaptors/common/adaptor-impl.cpp
adaptors/common/adaptor-impl.h

index 860e581..47b0bb3 100644 (file)
@@ -739,15 +739,9 @@ void Adaptor::RequestUpdate()
 void Adaptor::RequestProcessEventsOnIdle()
 {
   // Only request a notification if the Adaptor is actually running
-  if ( RUNNING == mState )
+  // and we haven't installed the idle notification
+  if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
   {
-    boost::unique_lock<boost::mutex> lock( mIdleInstaller );
-
-    // check if the idle handle is already installed
-    if( mNotificationOnIdleInstalled )
-    {
-      return;
-    }
     mNotificationOnIdleInstalled = AddIdle( boost::bind( &Adaptor::ProcessCoreEventsFromIdle, this ) );
   }
 }
index c03d0a8..4979cc3 100644 (file)
@@ -404,7 +404,8 @@ private: // From Dali::Integration::RenderController
   virtual void RequestUpdate();
 
   /**
-   * Call by the Dali core when it requires an notification event being sent on idle
+   * Called by Dali core when it requires an notification event being sent on idle.
+   * Multi-threading note: this method must be called from the main thread only.
    */
   virtual void RequestProcessEventsOnIdle();
 
@@ -503,7 +504,6 @@ private: // Data
   bool                                  mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event
   TriggerEvent*                         mNotificationTrigger;         ///< Notification event trigger
   GestureManager*                       mGestureManager;              ///< Gesture manager
-  boost::mutex                          mIdleInstaller;               ///< mutex to ensure two threads don't try to install idle handler at the same time
   size_t                                mHDpi;                        ///< Override horizontal DPI
   size_t                                mVDpi;                        ///< Override vertical DPI
   FeedbackPluginProxy*                  mDaliFeedbackPlugin;          ///< Used to access feedback support