class RenderThread

Manager for the render thread.

Takes care of starting, running, queuing commands and shutting down the render thread.

Commands from various threads can be queued for execution on the render thread by calling PostCommand()

Public

Constructors

RenderThread

RenderThread()

Methods

~RenderThread

~RenderThread() noexcept

OnStartUp

void OnStartUp() override

Override if you want your module to be notified once it has been constructed and started.

GetThreadId

ThreadId GetThreadId() const

Returns the id of the render thread.

PostCommand

void PostCommand(std::function<void ()> &&commandCallback, const char *debugName = "Render thread command", bool waitUntilComplete = false, const String &extraDebugInformation = StringUtility::kBlank)

Queues a new command that will be added to the render thread command queue.

commandCallback
Command to queue.
debugName
Optional name for identifying the command more easily.
waitUntilComplete
If true, the caller will block until the command finishes executing.
extraDebugInformation
Additional information for debugging (e.g. associated object name).

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Protected

Methods

~Module<T>

virtual ~Module<T>() = default

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Fields

mRenderThreadStarted

bool mRenderThreadStarted

mScheduler

Scheduler mScheduler

mRenderThreadId

ThreadId mRenderThreadId

mThreadStartedMutex

Mutex mThreadStartedMutex

mThreadStartedCondition

ConditionVariable mThreadStartedCondition

mRenderThread

SPtr<PooledThread> mRenderThread

mCommandQueue

SingleConsumerQueue mCommandQueue