#include <errno.h>
#include <dali/integration-api/platform-abstraction.h>
#include <unistd.h>
+#include "dali/public-api/common/dali-common.h"
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode )
: mFpsTracker( environmentOptions ),
mUpdateStatusLogger( environmentOptions ),
- mEventThreadSemaphore(),
- mGraphicsInitializeSemaphore(),
- mSurfaceSemaphore(),
+ mEventThreadSemaphore(0),
+ mSurfaceSemaphore(0),
mUpdateRenderThreadWaitCondition(),
mAdaptorInterfaces( adaptorInterfaces ),
mPerformanceInterface( adaptorInterfaces.GetPerformanceInterface() ),
}
mSleepTrigger = TriggerEventFactory::CreateTriggerEvent( MakeCallback( this, &CombinedUpdateRenderController::ProcessSleepRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER );
-
- // Initialize to 0 so that it just waits if sem_post has not been called
- sem_init( &mEventThreadSemaphore, 0, 0 );
- sem_init( &mGraphicsInitializeSemaphore, 0, 0 );
- sem_init( &mSurfaceSemaphore, 0, 0 );
}
CombinedUpdateRenderController::~CombinedUpdateRenderController()
DALI_ASSERT_ALWAYS( ! mUpdateRenderThread );
// Create Update/Render Thread
+ ConditionalWait::ScopedLock lock(mGraphicsInitializeWait);
mUpdateRenderThread = new pthread_t();
int error = pthread_create( mUpdateRenderThread, NULL, InternalUpdateRenderThreadEntryFunc, this );
DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() when creating UpdateRenderThread" );
// Wait until all threads created in Initialise are up and running
for( unsigned int i = 0; i < CREATED_THREAD_COUNT; ++i )
{
- sem_wait( &mEventThreadSemaphore );
+ mEventThreadSemaphore.Acquire();
}
Dali::RenderSurfaceInterface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
}
// Wait until the surface has been replaced
- sem_wait( &mSurfaceSemaphore );
+ mSurfaceSemaphore.Acquire();
LOG_EVENT( "Surface replaced, event-thread continuing" );
}
}
// Wait until the surface has been deleted
- sem_wait( &mSurfaceSemaphore );
+ mSurfaceSemaphore.Acquire();
LOG_EVENT( "Surface deleted, event-thread continuing" );
}
void CombinedUpdateRenderController::WaitForGraphicsInitialization()
{
+ ConditionalWait::ScopedLock lk(mGraphicsInitializeWait);
LOG_EVENT_TRACE;
if( mUpdateRenderThread )
LOG_EVENT( "Waiting for graphics initialisation, event-thread blocked" );
// Wait until the graphics has been initialised
- sem_wait( &mGraphicsInitializeSemaphore );
+ mGraphicsInitializeWait.Wait(lk);
LOG_EVENT( "graphics initialised, event-thread continuing" );
}
void CombinedUpdateRenderController::SurfaceReplaced()
{
// Just increment the semaphore
- sem_post( &mSurfaceSemaphore );
+ mSurfaceSemaphore.Release(1);
}
Dali::RenderSurfaceInterface* CombinedUpdateRenderController::ShouldSurfaceBeDeleted()
void CombinedUpdateRenderController::SurfaceDeleted()
{
// Just increment the semaphore
- sem_post( &mSurfaceSemaphore );
+ mSurfaceSemaphore.Release(1);
}
bool CombinedUpdateRenderController::ShouldSurfaceBeResized()
void CombinedUpdateRenderController::NotifyThreadInitialised()
{
// Just increment the semaphore
- sem_post( &mEventThreadSemaphore );
+ mEventThreadSemaphore.Release(1);
}
void CombinedUpdateRenderController::NotifyGraphicsInitialised()
{
- sem_post( &mGraphicsInitializeSemaphore );
+ mGraphicsInitializeWait.Notify();
}
void CombinedUpdateRenderController::AddPerformanceMarker( PerformanceInterface::MarkerType type )
#include <atomic>
#include <stdint.h>
#include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/devel-api/threading/semaphore.h>
#include <dali/integration-api/core.h>
// INTERNAL INCLUDES
FpsTracker mFpsTracker; ///< Object that tracks the FPS
UpdateStatusLogger mUpdateStatusLogger; ///< Object that logs the update-status as required.
- sem_t mEventThreadSemaphore; ///< Used by the event thread to ensure all threads have been initialised.
- sem_t mGraphicsInitializeSemaphore; ///< Used by the render thread to ensure the graphics has been initialised.
- sem_t mSurfaceSemaphore; ///< Used by the event thread to ensure the surface has been deleted or replaced.
+ Semaphore<> mEventThreadSemaphore; ///< Used by the event thread to ensure all threads have been initialised, and when replacing the surface.
+ ConditionalWait mGraphicsInitializeWait; ///< Used by the render thread to ensure the graphics has been initialised.
+ Semaphore<> mSurfaceSemaphore; ///< Used by the event thread to ensure the surface has been deleted or replaced.
ConditionalWait mUpdateRenderThreadWaitCondition; ///< The wait condition for the update-render-thread.