Replace boost::thread with pthread in render,update & vsync thread 15/42615/4
authorXiangyin Ma <x1.ma@samsung.com>
Tue, 30 Jun 2015 14:56:58 +0000 (15:56 +0100)
committerXiangyin Ma <x1.ma@samsung.com>
Wed, 1 Jul 2015 10:37:23 +0000 (03:37 -0700)
Change-Id: I3f6259cd6174b39fcf00f5e0b7b09e62f9f2cb71

adaptors/base/render-thread.cpp
adaptors/base/render-thread.h
adaptors/base/update-thread.cpp
adaptors/base/update-thread.h
adaptors/base/vsync-notifier.cpp
adaptors/base/vsync-notifier.h

index 7ef886b..c30add5 100644 (file)
@@ -119,7 +119,9 @@ void RenderThread::Start()
   DALI_ASSERT_ALWAYS( !mEGL && "Egl already initialized" );
 
   // create the render thread, initially we are rendering
-  mThread = new boost::thread(boost::bind(&RenderThread::Run, this));
+  mThread = new pthread_t();
+  int error = pthread_create( mThread, NULL, InternalThreadEntryFunc, this );
+  DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() in RenderThread" );
 
   mSurface->StartRender();
 }
@@ -135,7 +137,7 @@ void RenderThread::Stop()
     mSurface->StopRender();
 
     // wait for the thread to finish
-    mThread->join();
+    pthread_join(*mThread, NULL);
 
     delete mThread;
     mThread = NULL;
index 246c3c6..09ba5b6 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
-#include <boost/thread.hpp>
+#include <pthread.h>
 
 // INTERNAL INCLUDES
 #include <egl-interface.h>
@@ -190,6 +190,16 @@ private: // Render thread side helpers
    */
   void PostRender( unsigned int timeDelta );
 
+  /**
+   * Helper for the thread calling the entry function.
+   * @param[in] This A pointer to the current RenderThread object
+   */
+  static inline void* InternalThreadEntryFunc( void* This )
+  {
+    ( static_cast<RenderThread*>( This ) )->Run();
+    return NULL;
+  }
+
 private: // Data
 
   UpdateRenderSynchronization&  mUpdateRenderSync;       ///< Used to synchronize the update & render threads
@@ -197,7 +207,7 @@ private: // Data
   Integration::GlAbstraction&   mGLES;                   ///< GL abstraction reference
   EglFactoryInterface*          mEglFactory;             ///< Factory class to create EGL implementation
   EglInterface*                 mEGL;                    ///< Interface to EGL implementation
-  boost::thread*                mThread;                 ///< render thread
+  pthread_t*                    mThread;                 ///< render thread
   RenderSurface*                mSurface;                ///< Current surface
   Dali::DisplayConnection*      mDisplayConnection;      ///< Display connection
   const EnvironmentOptions&     mEnvironmentOptions;     ///< Environment options
index 7c84964..18c9d6c 100644 (file)
@@ -19,7 +19,6 @@
 #include "update-thread.h"
 
 // EXTERNAL INCLUDES
-#include <boost/thread.hpp>
 #include <cstdio>
 
 // INTERNAL INCLUDES
@@ -76,7 +75,9 @@ void UpdateThread::Start()
   if ( !mThread )
   {
     // Create and run the update-thread
-    mThread = new boost::thread( boost::bind( &UpdateThread::Run, this ) );
+    mThread =  new pthread_t();
+    int error = pthread_create( mThread, NULL, InternalThreadEntryFunc, this );
+    DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() in UpdateThread" );
   }
 }
 
@@ -86,7 +87,7 @@ void UpdateThread::Stop()
   if( mThread )
   {
     // wait for the thread to finish
-    mThread->join();
+    pthread_join(*mThread, NULL);
 
     delete mThread;
     mThread = NULL;
index d81f623..2b2b77e 100644 (file)
  *
  */
 
-namespace boost
-{
-class thread;
-} // namespace boost
+// EXTERNAL INCLUDES
+#include <pthread.h>
 
 namespace Dali
 {
@@ -101,6 +99,16 @@ private:
    */
   void UpdateStatusLogging( unsigned int keepUpdatingStatus, bool renderNeedsUpdate );
 
+  /**
+   * Helper for the thread calling the entry function
+   * @param[in] This A pointer to the current UpdateThread object
+   */
+  static inline void* InternalThreadEntryFunc( void* This )
+  {
+    ( static_cast<UpdateThread*>( This ) )->Run();
+    return NULL;
+  }
+
 private: // Data
 
   UpdateRenderSynchronization&        mUpdateRenderSync;    ///< Used to synchronize the update & render threads
@@ -114,7 +122,7 @@ private: // Data
   unsigned int                        mStatusLogInterval;   ///< Interval in frames between status debug prints
   unsigned int                        mStatusLogCount;      ///< Used to count frames between status debug prints
 
-  boost::thread*                      mThread;              ///< The actual update-thread.
+  pthread_t*                          mThread;              ///< The actual update-thread.
   const EnvironmentOptions&           mEnvironmentOptions;  ///< environment options
 }; // class UpdateThread
 
index e459df6..2511e7b 100644 (file)
@@ -18,9 +18,6 @@
 // CLASS HEADER
 #include "vsync-notifier.h"
 
-// EXTERNAL INCLUDES
-#include <boost/thread.hpp>
-
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/platform-abstraction.h>
 
@@ -78,7 +75,9 @@ void VSyncNotifier::Start()
   {
     mVSyncMonitor->Initialize();
 
-    mThread = new boost::thread( boost::bind( &VSyncNotifier::Run, this ) );
+    mThread = new pthread_t();
+    int error = pthread_create( mThread, NULL, InternalThreadEntryFunc, this );
+    DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() in VSyncNotifier" );
   }
 }
 
@@ -89,7 +88,7 @@ void VSyncNotifier::Stop()
   if( mThread )
   {
     // wait for the thread to finish
-    mThread->join();
+    pthread_join(*mThread, NULL);
 
     delete mThread;
     mThread = NULL;
index e2e28c4..c1c632d 100644 (file)
  *
  */
 
-namespace boost
-{
-
-class thread;
-
-} // namespace boost
+// EXTERNAL INCLUDES
+#include <pthread.h>
 
 namespace Dali
 {
@@ -89,13 +85,23 @@ private:
    */
   void Run();
 
+  /**
+   * Helper for the thread calling the entry function
+   * @param[in] This A pointer to the current VSyncNotifier object
+   */
+  static inline void* InternalThreadEntryFunc( void* This )
+  {
+    ( static_cast<VSyncNotifier*>( This ) )->Run();
+    return NULL;
+  }
+
 private:
 
   UpdateRenderSynchronization&        mUpdateRenderSync;    ///< Used to synchronize the update, render & vsync threads
   Dali::Integration::Core&            mCore;                ///< Dali core reference
   Integration::PlatformAbstraction&   mPlatformAbstraction; ///< The platform abstraction for retrieving the current time etc.
   VSyncMonitorInterface*              mVSyncMonitor;        ///< VSyncMonitor interface
-  boost::thread*                      mThread;              ///< The actual thread.
+  pthread_t*                          mThread;              ///< The actual thread.
   const EnvironmentOptions&           mEnvironmentOptions;  ///< Environment options
   unsigned int                        mNumberOfVSyncsPerRender;///< How many frames for each update/render cycle.