Dali 3D User Interface Engine
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
Dali::Internal::Adaptor::ThreadSynchronization Class Reference

This object is used to synchronize the update, render and vsync threads. More...

#include <thread-synchronization.h>

Inheritance diagram for Dali::Internal::Adaptor::ThreadSynchronization:
Inheritance graph
[legend]
Collaboration diagram for Dali::Internal::Adaptor::ThreadSynchronization:
Collaboration graph
[legend]

Classes

struct  State
 

Public Member Functions

 ThreadSynchronization (AdaptorInternalServices &adaptorInterfaces, unsigned int numberOfVSyncsPerRender)
 Create an update/render synchronization object. More...
 
 ~ThreadSynchronization ()
 Non virtual destructor. More...
 
void Initialise ()
 Initialises the ThreadSynchronisation class. More...
 
void Start ()
 Starts running all threads. More...
 
void Stop ()
 Stop the threads. More...
 
void Pause ()
 Pause the controller (and threads). More...
 
void Resume ()
 Resume the controller (and threads). More...
 
void UpdateRequest ()
 Wake update thread if sleeping. More...
 
void UpdateOnce ()
 Update once (even if paused) More...
 
void ReplaceSurface (RenderSurface *newSurface)
 Inform the render thread that there is a new surface, and that it should replace the current surface. More...
 
void SetRenderRefreshRate (unsigned int numberOfVSyncsPerRender)
 Set the refresh rate for rendering. More...
 
bool UpdateReady (bool notifyEvent, bool runUpdate, float &lastFrameDeltaSeconds, unsigned int &lastSyncTimeMilliseconds, unsigned int &nextSyncTimeMilliseconds)
 Called by Update thread when it is ready to run the update. More...
 
bool RenderReady (RenderRequest *&request)
 Called by the Render thread when it is ready to render. More...
 
void RenderFinished ()
 Called by the render thread after it renders a frame. More...
 
void RenderInformSurfaceReplaced ()
 Called by the Render thread to inform the synchronization class that the surface has been replaced. More...
 
bool VSyncReady (bool validSync, unsigned int frameNumber, unsigned int seconds, unsigned int microseconds, unsigned int &numberOfVSyncsPerRender)
 Called by the VSync notifier thread so it can sleep if Update/Render threads are sleeping/paused. More...
 
void PostRenderComplete ()
  More...
 
void PostRenderStarted ()
  More...
 
void PostRenderWaitForCompletion ()
  More...
 
void AddPerformanceMarker (PerformanceInterface::MarkerType type)
 Helper to add a performance marker to the performance server (if it's active) More...
 

Private Member Functions

 ThreadSynchronization (const ThreadSynchronization &)
 
ThreadSynchronizationoperator= (const ThreadSynchronization &)
 
void NotifyThreadInitialised ()
 Called by the update, render & v-sync thread when they up and running. More...
 
void UpdateInitialising ()
 Called by the update-thread when the state is State::INITIALISING. More...
 
void UpdateTryToSleep (bool runUpdate)
 Called by the update thread to attempt to sleep. More...
 
void UpdateWaitIfReplacingSurface ()
 Called by the update thread to wait while the render-surface is being replaced. More...
 
bool IsUpdateThreadResuming ()
 Called by the update thread to check if we're just resuming. More...
 
bool IsUpdateThreadStopping ()
 Called by the update thread to check if the update thread should be running. More...
 
bool MaximumUpdateAheadOfRenderReached ()
 Called by the update thread to check if we've filled all update buffers. More...
 
void StopAllThreads ()
 Called by the update thread when we are about to stop. More...
 
void RunVSyncThread ()
 Runs the V-Sync Thread. More...
 
void PauseVSyncThread ()
 Pauses the V-Sync Thread. More...
 
void StopVSyncThread ()
 Stops the V-Sync Thread. More...
 
void StopRenderThread ()
 Stops the Render Thread. More...
 
bool IsVSyncThreadRunning ()
 Checks if the V-Sync thread should be running. More...
 
bool IsRenderThreadRunning ()
 Checks if the Render thread should be running. More...
 
bool IsRenderThreadReplacingSurface ()
 Checks if the render thread should be replacing the surface This will lock the mutex in mRenderThreadWaitCondition. More...
 

Private Attributes

FrameTime mFrameTime
 Frame timer predicts next vsync time. More...
 
TriggerEventInterface & mNotificationTrigger
 Reference to notification event trigger. More...
 
PerformanceInterfacemPerformanceInterface
 The performance logging interface. More...
 
ReplaceSurfaceRequest mReplaceSurfaceRequest
 Holder for a replace surface request. More...
 
ConditionalWait mUpdateThreadWaitCondition
 The wait condition for the update-thread. More...
 
ConditionalWait mRenderThreadWaitCondition
 The wait condition for the render-thread. More...
 
ConditionalWait mVSyncThreadWaitCondition
 The wait condition for the v-sync-thread. More...
 
ConditionalWait mEventThreadWaitCondition
 The wait condition for the event-thread. More...
 
const int mMaximumUpdateCount
 How many frames may be prepared, ahead of the rendering. More...
 
unsigned int mNumberOfVSyncsPerRender
 How many frames for each update/render cycle. More...
 
unsigned int mTryToSleepCount
 Count to ensure we don't go to sleep too early. More...
 
volatile State::Type mState
 The current state of synchronisation (set & read by both the event & update threads). More...
 
volatile int mVSyncAheadOfUpdate
 The number of frames vsync is ahead of update (set & read by both the v-sync & update threads). More...
 
volatile int mUpdateAheadOfRender
 The number of frames update is ahead of render (set & read by both the update & render threads). More...
 
volatile int mNumberOfThreadsStarted
 The number of threads that are initialised and running (set by update, v-sync & render threads, read by event-thread). More...
 
volatile unsigned int mUpdateThreadResuming
 Whether the update-thread is resuming. More...
 
volatile unsigned int mVSyncThreadRunning
 Whether the V-Sync thread is running (set by the update-thread, read by v-sync-thread). More...
 
volatile unsigned int mVSyncThreadStop
 Whether the V-Sync thread should be stopped (set by the update-thread, read by the v-sync-thread). More...
 
volatile unsigned int mRenderThreadStop
 Whether the render-thread should be stopped (set by the update-thread, read by the render-thread). More...
 
volatile unsigned int mRenderThreadReplacingSurface
 Whether the render-thread should replace the surface (set by the event & render threads, read by the render-thread). More...
 
volatile unsigned int mRenderThreadPostRendering
 Whether post-rendering is taking place (set by the event & render threads, read by the render-thread). More...
 
volatile unsigned int mEventThreadSurfaceReplaced
 Checked by the event-thread & set by the render-thread when the surface has been replaced (set by the event & render threads, read by the event-thread). More...
 
unsigned int mVSyncThreadInitialised
 Whether the V-Sync thread has been initialised (only used by v-sync-thread). More...
 
unsigned int mRenderThreadInitialised
 Whether the render-thread has been initialised (only used by the render-thread). More...
 
unsigned int mRenderThreadSurfaceReplaced
 Whether the render-thread has replaced the surface (only used by render-thread). More...
 

Detailed Description

This object is used to synchronize the update, render and vsync threads.

The Core::GetMaximumUpdateCount() method determines how many frames may be prepared, ahead of the rendering. For example if the maximum update count is 2, then Core::Update() for frame N+1 may be processed whilst frame N is being rendered. However the Core::Update() for frame N+2 may not be called, until the Core::Render() method for frame N has returned.

Definition at line 51 of file thread-synchronization.h.

Constructor & Destructor Documentation

Dali::Internal::Adaptor::ThreadSynchronization::ThreadSynchronization ( AdaptorInternalServices adaptorInterfaces,
unsigned int  numberOfVSyncsPerRender 
)

Create an update/render synchronization object.

Parameters
[in]adaptorInterfacesbase adaptor interface
[in]numberOfVSyncsPerRenderThe number of frames per render

Definition at line 42 of file thread-synchronization.cpp.

Dali::Internal::Adaptor::ThreadSynchronization::~ThreadSynchronization ( )

Non virtual destructor.

Not intended as base class.

Definition at line 71 of file thread-synchronization.cpp.

Dali::Internal::Adaptor::ThreadSynchronization::ThreadSynchronization ( const ThreadSynchronization )
private

Member Function Documentation

void Dali::Internal::Adaptor::ThreadSynchronization::AddPerformanceMarker ( PerformanceInterface::MarkerType  type)

Helper to add a performance marker to the performance server (if it's active)

Parameters
typeperformance marker type

Definition at line 639 of file thread-synchronization.cpp.

References Dali::Internal::Adaptor::PerformanceInterface::AddMarker(), and mPerformanceInterface.

Referenced by Pause(), Resume(), Dali::Internal::Adaptor::UpdateThread::Run(), Dali::Internal::Adaptor::VSyncNotifier::Run(), and Dali::Internal::Adaptor::RenderThread::Run().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::Initialise ( )

Initialises the ThreadSynchronisation class.

The expectation is that this function will be called when all threads are about to be set up and that Start will be called when the the scene is actually prepared and ready to be displayed. This way our first update will have the actual scene we require.

Note
Should only be called by the Event Thread.

Definition at line 79 of file thread-synchronization.cpp.

References Dali::Internal::Adaptor::ThreadSynchronization::State::INITIALISING, LOG_EVENT, LOG_EVENT_TRACE, mState, mUpdateThreadWaitCondition, and Dali::Internal::Adaptor::ThreadSynchronization::State::STOPPED.

Referenced by Dali::Internal::Adaptor::SeparateUpdateRenderController::Initialize().

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::IsRenderThreadReplacingSurface ( )
inlineprivate

Checks if the render thread should be replacing the surface This will lock the mutex in mRenderThreadWaitCondition.

Returns
true if the render thread should be replacing the surface, false otherwise.

Definition at line 874 of file thread-synchronization.cpp.

References mRenderThreadReplacingSurface, and mRenderThreadWaitCondition.

Referenced by RenderReady().

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::IsRenderThreadRunning ( )
inlineprivate

Checks if the Render thread should be running.

This will lock the mutex in mRenderThreadWaitCondition.

Returns
true if running, false otherwise.

Definition at line 868 of file thread-synchronization.cpp.

References mRenderThreadStop, and mRenderThreadWaitCondition.

Referenced by RenderReady().

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::IsUpdateThreadResuming ( )
inlineprivate

Called by the update thread to check if we're just resuming.

This will lock the mutex in mUpdateThreadWaitCondition.

Definition at line 794 of file thread-synchronization.cpp.

References mUpdateThreadResuming, and mUpdateThreadWaitCondition.

Referenced by UpdateReady(), and UpdateTryToSleep().

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::IsUpdateThreadStopping ( )
inlineprivate

Called by the update thread to check if the update thread should be running.

This will lock the mutex in mUpdateThreadWaitCondition.

Returns
True if we're stopping, false otherwise.

Definition at line 800 of file thread-synchronization.cpp.

References mState, mUpdateThreadWaitCondition, and Dali::Internal::Adaptor::ThreadSynchronization::State::STOPPED.

Referenced by UpdateReady().

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::IsVSyncThreadRunning ( )
inlineprivate

Checks if the V-Sync thread should be running.

This will lock the mutex in mVSyncThreadWaitCondition.

Returns
true if running, false otherwise.

Definition at line 858 of file thread-synchronization.cpp.

References mVSyncThreadStop, and mVSyncThreadWaitCondition.

Referenced by VSyncReady().

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::MaximumUpdateAheadOfRenderReached ( )
inlineprivate

Called by the update thread to check if we've filled all update buffers.

This will lock the mutex in mRenderThreadWaitCondition.

Returns
True if all update buffers are full.

Definition at line 806 of file thread-synchronization.cpp.

References mMaximumUpdateCount, mRenderThreadWaitCondition, and mUpdateAheadOfRender.

Referenced by UpdateReady().

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::NotifyThreadInitialised ( )
inlineprivate

Called by the update, render & v-sync thread when they up and running.

This will lock the mutex in mEventThreadWaitCondition.

Definition at line 657 of file thread-synchronization.cpp.

References mEventThreadWaitCondition, mNumberOfThreadsStarted, and Dali::ConditionalWait::Notify().

Referenced by RenderReady(), UpdateInitialising(), and VSyncReady().

Here is the call graph for this function:

Here is the caller graph for this function:

ThreadSynchronization& Dali::Internal::Adaptor::ThreadSynchronization::operator= ( const ThreadSynchronization )
private
void Dali::Internal::Adaptor::ThreadSynchronization::Pause ( )
void Dali::Internal::Adaptor::ThreadSynchronization::PauseVSyncThread ( )
inlineprivate

Pauses the V-Sync Thread.

This will lock the mutex in mVSyncThreadWaitCondition.

Definition at line 830 of file thread-synchronization.cpp.

References Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::FALSE, mVSyncThreadRunning, and mVSyncThreadWaitCondition.

Referenced by UpdateReady(), UpdateTryToSleep(), and UpdateWaitIfReplacingSurface().

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::PostRenderComplete ( )
void Dali::Internal::Adaptor::ThreadSynchronization::PostRenderStarted ( )
void Dali::Internal::Adaptor::ThreadSynchronization::PostRenderWaitForCompletion ( )
void Dali::Internal::Adaptor::ThreadSynchronization::RenderFinished ( )

Called by the render thread after it renders a frame.

Used to notify the update-thread that a frame has been rendered.

Precondition
Called by render thread only.

Definition at line 503 of file thread-synchronization.cpp.

References DALI_ASSERT_ALWAYS, LOG_RENDER, mMaximumUpdateCount, mRenderThreadWaitCondition, and mUpdateAheadOfRender.

Referenced by Dali::Internal::Adaptor::RenderThread::Run().

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::RenderInformSurfaceReplaced ( )

Called by the Render thread to inform the synchronization class that the surface has been replaced.

Note
Should only be called by the Render thread.

Definition at line 514 of file thread-synchronization.cpp.

References LOG_RENDER_TRACE, mEventThreadSurfaceReplaced, mEventThreadWaitCondition, mRenderThreadSurfaceReplaced, Dali::ConditionalWait::Notify(), and Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::TRUE.

Referenced by Dali::Internal::Adaptor::RenderThread::ProcessRequest().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::RenderReady ( RenderRequest *&  request)

Called by the Render thread when it is ready to render.

Parameters
[in]requestPointer to set if there are any requests. This does not need to be freed by the caller.
Note
Should only be called by the Render thread.
If there is a request, then the Render thread should NOT perform a Render and only process the request

Definition at line 446 of file thread-synchronization.cpp.

References Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::FALSE, IsRenderThreadReplacingSurface(), IsRenderThreadRunning(), LOG_RENDER, LOG_RENDER_TRACE, LOG_UPDATE_COUNTER_RENDER, mRenderThreadInitialised, mRenderThreadReplacingSurface, mRenderThreadStop, mRenderThreadSurfaceReplaced, mRenderThreadWaitCondition, mReplaceSurfaceRequest, mUpdateAheadOfRender, NotifyThreadInitialised(), Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::TRUE, and Dali::ConditionalWait::Wait().

Referenced by Dali::Internal::Adaptor::RenderThread::Run().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::ReplaceSurface ( RenderSurface *  newSurface)
void Dali::Internal::Adaptor::ThreadSynchronization::Resume ( )
void Dali::Internal::Adaptor::ThreadSynchronization::RunVSyncThread ( )
inlineprivate

Runs the V-Sync Thread.

This will lock the mutex in mVSyncThreadWaitCondition.

Definition at line 821 of file thread-synchronization.cpp.

References mVSyncThreadRunning, mVSyncThreadWaitCondition, Dali::ConditionalWait::Notify(), and Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::TRUE.

Referenced by UpdateInitialising(), UpdateReady(), UpdateTryToSleep(), and UpdateWaitIfReplacingSurface().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::SetRenderRefreshRate ( unsigned int  numberOfVSyncsPerRender)

Set the refresh rate for rendering.

Parameters
[in]numberOfVSyncsPerRenderThe number of vsync frames per render
Note
Should only be called by the Event Thread.

Definition at line 296 of file thread-synchronization.cpp.

References LOG_EVENT, LOG_EVENT_TRACE, and mNumberOfVSyncsPerRender.

Referenced by Dali::Internal::Adaptor::SeparateUpdateRenderController::SetRenderRefreshRate().

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::Start ( )
void Dali::Internal::Adaptor::ThreadSynchronization::Stop ( )

Stop the threads.

Note
Should only be called by the Event Thread.

Definition at line 126 of file thread-synchronization.cpp.

References LOG_EVENT, LOG_EVENT_TRACE, mFrameTime, mState, mUpdateThreadWaitCondition, Dali::ConditionalWait::Notify(), Dali::Internal::Adaptor::ThreadSynchronization::State::STOPPED, and Dali::Internal::Adaptor::FrameTime::Suspend().

Referenced by Dali::Internal::Adaptor::SeparateUpdateRenderController::Stop().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::StopAllThreads ( )
inlineprivate

Called by the update thread when we are about to stop.

This will call other functions which lock various conditional wait mutexes.

Definition at line 812 of file thread-synchronization.cpp.

References LOG_UPDATE_TRACE, StopRenderThread(), and StopVSyncThread().

Referenced by UpdateReady().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::StopRenderThread ( )
inlineprivate

Stops the Render Thread.

This will lock the mutex in mRenderThreadWaitCondition.

Definition at line 845 of file thread-synchronization.cpp.

References mRenderThreadStop, mRenderThreadWaitCondition, Dali::ConditionalWait::Notify(), and Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::TRUE.

Referenced by StopAllThreads().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::StopVSyncThread ( )
inlineprivate

Stops the V-Sync Thread.

This will lock the mutex in mVSyncThreadWaitCondition.

Definition at line 836 of file thread-synchronization.cpp.

References mVSyncThreadStop, mVSyncThreadWaitCondition, Dali::ConditionalWait::Notify(), and Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::TRUE.

Referenced by StopAllThreads().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::UpdateInitialising ( )
private

Called by the update-thread when the state is State::INITIALISING.

Calls methods that lock and locks itself so should NOT be called while a scoped-lock is held.

Definition at line 670 of file thread-synchronization.cpp.

References Dali::Internal::Adaptor::ThreadSynchronization::State::INITIALISING, LOG_UPDATE_TRACE, mState, mUpdateThreadWaitCondition, NotifyThreadInitialised(), RunVSyncThread(), and Dali::ConditionalWait::Wait().

Referenced by UpdateReady().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::UpdateOnce ( )

Update once (even if paused)

Note
Should only be called by the Event Thread.

Definition at line 235 of file thread-synchronization.cpp.

References LOG_EVENT, LOG_EVENT_TRACE, mState, mUpdateThreadWaitCondition, Dali::ConditionalWait::Notify(), Dali::Internal::Adaptor::ThreadSynchronization::State::RUNNING, and Dali::Internal::Adaptor::ThreadSynchronization::State::SLEEPING.

Referenced by Dali::Internal::Adaptor::SeparateUpdateRenderController::RequestUpdateOnce().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::UpdateReady ( bool  notifyEvent,
bool  runUpdate,
float &  lastFrameDeltaSeconds,
unsigned int &  lastSyncTimeMilliseconds,
unsigned int &  nextSyncTimeMilliseconds 
)

Called by Update thread when it is ready to run the update.

Parameters
[in]notifyEventWhether the event thread should be woken up.
[in]runUpdateWhether to run another update. If false, then the update-thread will attempt to sleep.
[out]lastFrameDeltaSecondsThe delta, in seconds (with float precision), between the last two renders.
[out]lastSyncTimeMillisecondsThe time, in milliseconds, of the last Sync.
[out]nextSyncTimeMillisecondsThe estimated time, in milliseconds, at the next Sync.
Returns
true if updating should continue, false if the update-thread should quit.
Note
Should only be called by the Update thread.

Definition at line 308 of file thread-synchronization.cpp.

References DALI_ASSERT_ALWAYS, Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::FALSE, Dali::Internal::Adaptor::ThreadSynchronization::State::INITIALISING, IsUpdateThreadResuming(), IsUpdateThreadStopping(), LOG_UPDATE, LOG_UPDATE_COUNTER_UPDATE, LOG_UPDATE_TRACE, LOG_UPDATE_TRACE_FMT, LOG_VSYNC_COUNTER_UPDATE, MaximumUpdateAheadOfRenderReached(), mFrameTime, mMaximumUpdateCount, mNotificationTrigger, mRenderThreadWaitCondition, mState, mUpdateAheadOfRender, mUpdateThreadResuming, mUpdateThreadWaitCondition, mVSyncAheadOfUpdate, Dali::ConditionalWait::Notify(), Dali::Internal::Adaptor::ThreadSynchronization::State::PAUSED, PauseVSyncThread(), Dali::Internal::Adaptor::FrameTime::PredictNextSyncTime(), Dali::Internal::Adaptor::ThreadSynchronization::State::REPLACING_SURFACE, Dali::Internal::Adaptor::ThreadSynchronization::State::RUNNING, RunVSyncThread(), Dali::Internal::Adaptor::ThreadSynchronization::State::SLEEPING, StopAllThreads(), Dali::Internal::Adaptor::ThreadSynchronization::State::STOPPED, UpdateInitialising(), UpdateTryToSleep(), UpdateWaitIfReplacingSurface(), and Dali::ConditionalWait::Wait().

Referenced by Dali::Internal::Adaptor::UpdateThread::Run().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::UpdateRequest ( )

Wake update thread if sleeping.

If the update thread is not sleeping this becomes a no-op. Called when an update is requested by Core. i.e. when a batch of messages have been queued for the next update.

Note
Should only be called by the Event Thread.

Definition at line 213 of file thread-synchronization.cpp.

References LOG_EVENT, LOG_EVENT_TRACE, mState, mTryToSleepCount, mUpdateThreadWaitCondition, Dali::ConditionalWait::Notify(), Dali::Internal::Adaptor::ThreadSynchronization::State::RUNNING, and Dali::Internal::Adaptor::ThreadSynchronization::State::SLEEPING.

Referenced by Dali::Internal::Adaptor::SeparateUpdateRenderController::RequestUpdate().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::UpdateTryToSleep ( bool  runUpdate)
private

Called by the update thread to attempt to sleep.

Parameters
[in]runUpdateWhether to run another update. If false, then the update-thread will attempt to sleep.

Definition at line 691 of file thread-synchronization.cpp.

References IsUpdateThreadResuming(), LOG_UPDATE, LOG_UPDATE_TRACE, mFrameTime, mState, mTryToSleepCount, mUpdateThreadWaitCondition, mVSyncAheadOfUpdate, PauseVSyncThread(), RunVSyncThread(), Dali::Internal::Adaptor::FrameTime::Sleep(), Dali::Internal::Adaptor::ThreadSynchronization::State::SLEEPING, Dali::Internal::Adaptor::ThreadSynchronization::State::STOPPED, Dali::ConditionalWait::Wait(), and Dali::Internal::Adaptor::FrameTime::WakeUp().

Referenced by UpdateReady().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::Adaptor::ThreadSynchronization::UpdateWaitIfReplacingSurface ( )
private

Called by the update thread to wait while the render-surface is being replaced.

Calls methods that lock and locks itself so should NOT be called while a scoped-lock is held.

Definition at line 760 of file thread-synchronization.cpp.

References LOG_UPDATE_TRACE_FMT, mState, mUpdateThreadWaitCondition, mVSyncAheadOfUpdate, PauseVSyncThread(), Dali::Internal::Adaptor::ThreadSynchronization::State::REPLACING_SURFACE, RunVSyncThread(), and Dali::ConditionalWait::Wait().

Referenced by UpdateReady().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Dali::Internal::Adaptor::ThreadSynchronization::VSyncReady ( bool  validSync,
unsigned int  frameNumber,
unsigned int  seconds,
unsigned int  microseconds,
unsigned int &  numberOfVSyncsPerRender 
)

Called by the VSync notifier thread so it can sleep if Update/Render threads are sleeping/paused.

Parameters
[in]validSyncTrue if the sync was valid (
See Also
VSyncMonitor::DoSync)
Parameters
[in]frameNumberThe current frame number
[in]secondsThe current time
[in]microsecondsThe current time
[out]numberOfVSyncsPerRenderThe number of frames per render.
Returns
true if VSync monitoring/notifications should continue.
Note
Should only be called by the VSync thread.
The first call to this method should be BEFORE the actual VSync so a thread-sync point can be established (and startup time is not delayed).

Definition at line 530 of file thread-synchronization.cpp.

References IsVSyncThreadRunning(), LOG_VSYNC, LOG_VSYNC_COUNTER_VSYNC, LOG_VSYNC_TRACE, mFrameTime, mNumberOfVSyncsPerRender, mUpdateThreadWaitCondition, mVSyncAheadOfUpdate, mVSyncThreadInitialised, mVSyncThreadRunning, mVSyncThreadStop, mVSyncThreadWaitCondition, Dali::ConditionalWait::Notify(), NotifyThreadInitialised(), Dali::Internal::Adaptor::FrameTime::SetMinimumFrameTimeInterval(), Dali::Internal::Adaptor::FrameTime::SetSyncTime(), Dali::Internal::Adaptor::anonymous_namespace{thread-synchronization.cpp}::TIME_PER_FRAME_IN_MICROSECONDS, Dali::Internal::Adaptor::anonymous_namespace{combined-update-render-controller.cpp}::TRUE, and Dali::ConditionalWait::Wait().

Referenced by Dali::Internal::Adaptor::VSyncNotifier::Run().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

volatile unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mEventThreadSurfaceReplaced
private

Checked by the event-thread & set by the render-thread when the surface has been replaced (set by the event & render threads, read by the event-thread).

Definition at line 423 of file thread-synchronization.h.

Referenced by RenderInformSurfaceReplaced(), and ReplaceSurface().

ConditionalWait Dali::Internal::Adaptor::ThreadSynchronization::mEventThreadWaitCondition
private

The wait condition for the event-thread.

Definition at line 396 of file thread-synchronization.h.

Referenced by NotifyThreadInitialised(), RenderInformSurfaceReplaced(), ReplaceSurface(), and Start().

FrameTime Dali::Internal::Adaptor::ThreadSynchronization::mFrameTime
private

Frame timer predicts next vsync time.

Definition at line 388 of file thread-synchronization.h.

Referenced by Pause(), Resume(), Start(), Stop(), UpdateReady(), UpdateTryToSleep(), and VSyncReady().

const int Dali::Internal::Adaptor::ThreadSynchronization::mMaximumUpdateCount
private

How many frames may be prepared, ahead of the rendering.

Definition at line 398 of file thread-synchronization.h.

Referenced by MaximumUpdateAheadOfRenderReached(), RenderFinished(), and UpdateReady().

TriggerEventInterface& Dali::Internal::Adaptor::ThreadSynchronization::mNotificationTrigger
private

Reference to notification event trigger.

Definition at line 389 of file thread-synchronization.h.

Referenced by UpdateReady().

volatile int Dali::Internal::Adaptor::ThreadSynchronization::mNumberOfThreadsStarted
private

The number of threads that are initialised and running (set by update, v-sync & render threads, read by event-thread).

Definition at line 407 of file thread-synchronization.h.

Referenced by NotifyThreadInitialised(), and Start().

unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mNumberOfVSyncsPerRender
private

How many frames for each update/render cycle.

Definition at line 399 of file thread-synchronization.h.

Referenced by SetRenderRefreshRate(), Start(), and VSyncReady().

PerformanceInterface* Dali::Internal::Adaptor::ThreadSynchronization::mPerformanceInterface
private

The performance logging interface.

Definition at line 390 of file thread-synchronization.h.

Referenced by AddPerformanceMarker().

unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mRenderThreadInitialised
private

Whether the render-thread has been initialised (only used by the render-thread).

Definition at line 426 of file thread-synchronization.h.

Referenced by RenderReady().

volatile unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mRenderThreadPostRendering
private

Whether post-rendering is taking place (set by the event & render threads, read by the render-thread).

Definition at line 421 of file thread-synchronization.h.

Referenced by PostRenderComplete(), PostRenderStarted(), and PostRenderWaitForCompletion().

volatile unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mRenderThreadReplacingSurface
private

Whether the render-thread should replace the surface (set by the event & render threads, read by the render-thread).

Definition at line 419 of file thread-synchronization.h.

Referenced by IsRenderThreadReplacingSurface(), PostRenderWaitForCompletion(), RenderReady(), and ReplaceSurface().

volatile unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mRenderThreadStop
private

Whether the render-thread should be stopped (set by the update-thread, read by the render-thread).

Definition at line 418 of file thread-synchronization.h.

Referenced by IsRenderThreadRunning(), RenderReady(), and StopRenderThread().

unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mRenderThreadSurfaceReplaced
private

Whether the render-thread has replaced the surface (only used by render-thread).

Definition at line 427 of file thread-synchronization.h.

Referenced by RenderInformSurfaceReplaced(), and RenderReady().

ConditionalWait Dali::Internal::Adaptor::ThreadSynchronization::mRenderThreadWaitCondition
private
ReplaceSurfaceRequest Dali::Internal::Adaptor::ThreadSynchronization::mReplaceSurfaceRequest
private

Holder for a replace surface request.

Definition at line 391 of file thread-synchronization.h.

Referenced by RenderReady(), and ReplaceSurface().

volatile State::Type Dali::Internal::Adaptor::ThreadSynchronization::mState
private

The current state of synchronisation (set & read by both the event & update threads).

Definition at line 403 of file thread-synchronization.h.

Referenced by Initialise(), IsUpdateThreadStopping(), Pause(), ReplaceSurface(), Resume(), Start(), Stop(), UpdateInitialising(), UpdateOnce(), UpdateReady(), UpdateRequest(), UpdateTryToSleep(), and UpdateWaitIfReplacingSurface().

unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mTryToSleepCount
private

Count to ensure we don't go to sleep too early.

Definition at line 401 of file thread-synchronization.h.

Referenced by UpdateRequest(), and UpdateTryToSleep().

volatile int Dali::Internal::Adaptor::ThreadSynchronization::mUpdateAheadOfRender
private

The number of frames update is ahead of render (set & read by both the update & render threads).

Definition at line 406 of file thread-synchronization.h.

Referenced by MaximumUpdateAheadOfRenderReached(), RenderFinished(), RenderReady(), and UpdateReady().

volatile unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mUpdateThreadResuming
private

Whether the update-thread is resuming.

Definition at line 413 of file thread-synchronization.h.

Referenced by IsUpdateThreadResuming(), Pause(), Resume(), and UpdateReady().

ConditionalWait Dali::Internal::Adaptor::ThreadSynchronization::mUpdateThreadWaitCondition
private
volatile int Dali::Internal::Adaptor::ThreadSynchronization::mVSyncAheadOfUpdate
private

The number of frames vsync is ahead of update (set & read by both the v-sync & update threads).

Definition at line 405 of file thread-synchronization.h.

Referenced by UpdateReady(), UpdateTryToSleep(), UpdateWaitIfReplacingSurface(), and VSyncReady().

unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mVSyncThreadInitialised
private

Whether the V-Sync thread has been initialised (only used by v-sync-thread).

Definition at line 425 of file thread-synchronization.h.

Referenced by VSyncReady().

volatile unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mVSyncThreadRunning
private

Whether the V-Sync thread is running (set by the update-thread, read by v-sync-thread).

Definition at line 415 of file thread-synchronization.h.

Referenced by PauseVSyncThread(), RunVSyncThread(), and VSyncReady().

volatile unsigned int Dali::Internal::Adaptor::ThreadSynchronization::mVSyncThreadStop
private

Whether the V-Sync thread should be stopped (set by the update-thread, read by the v-sync-thread).

Definition at line 416 of file thread-synchronization.h.

Referenced by IsVSyncThreadRunning(), StopVSyncThread(), and VSyncReady().

ConditionalWait Dali::Internal::Adaptor::ThreadSynchronization::mVSyncThreadWaitCondition
private

The wait condition for the v-sync-thread.

Definition at line 395 of file thread-synchronization.h.

Referenced by IsVSyncThreadRunning(), PauseVSyncThread(), RunVSyncThread(), StopVSyncThread(), and VSyncReady().


The documentation for this class was generated from the following files:
Dali Docs Home
Read more about Dali