From: Xiangyin Ma Date: Tue, 30 Jun 2015 14:56:58 +0000 (+0100) Subject: Replace boost::thread with pthread in render,update & vsync thread X-Git-Tag: dali_1.0.48~8^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=798bf0321f4d3b2f9bf1e089bef90e479a9a78c8;hp=b24b5d85259f858692f14059b77f266d77438c29;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Replace boost::thread with pthread in render,update & vsync thread Change-Id: I3f6259cd6174b39fcf00f5e0b7b09e62f9f2cb71 --- diff --git a/adaptors/base/render-thread.cpp b/adaptors/base/render-thread.cpp index 7ef886b..c30add5 100644 --- a/adaptors/base/render-thread.cpp +++ b/adaptors/base/render-thread.cpp @@ -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; diff --git a/adaptors/base/render-thread.h b/adaptors/base/render-thread.h index 246c3c6..09ba5b6 100644 --- a/adaptors/base/render-thread.h +++ b/adaptors/base/render-thread.h @@ -19,7 +19,7 @@ */ // EXTERNAL INCLUDES -#include +#include // INTERNAL INCLUDES #include @@ -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( 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 diff --git a/adaptors/base/update-thread.cpp b/adaptors/base/update-thread.cpp index 7c84964..18c9d6c 100644 --- a/adaptors/base/update-thread.cpp +++ b/adaptors/base/update-thread.cpp @@ -19,7 +19,6 @@ #include "update-thread.h" // EXTERNAL INCLUDES -#include #include // 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; diff --git a/adaptors/base/update-thread.h b/adaptors/base/update-thread.h index d81f623..2b2b77e 100644 --- a/adaptors/base/update-thread.h +++ b/adaptors/base/update-thread.h @@ -18,10 +18,8 @@ * */ -namespace boost -{ -class thread; -} // namespace boost +// EXTERNAL INCLUDES +#include 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( 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 diff --git a/adaptors/base/vsync-notifier.cpp b/adaptors/base/vsync-notifier.cpp index e459df6..2511e7b 100644 --- a/adaptors/base/vsync-notifier.cpp +++ b/adaptors/base/vsync-notifier.cpp @@ -18,9 +18,6 @@ // CLASS HEADER #include "vsync-notifier.h" -// EXTERNAL INCLUDES -#include - #include #include @@ -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; diff --git a/adaptors/base/vsync-notifier.h b/adaptors/base/vsync-notifier.h index e2e28c4..c1c632d 100644 --- a/adaptors/base/vsync-notifier.h +++ b/adaptors/base/vsync-notifier.h @@ -18,12 +18,8 @@ * */ -namespace boost -{ - -class thread; - -} // namespace boost +// EXTERNAL INCLUDES +#include 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( 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.