class render::RendererTask

Task that represents an asynchonous operation queued for execution on the render thread.

All such tasks are executed before main rendering happens, every frame.

Public

Constructors

RendererTask

RendererTask(const PrivatelyConstruct &dummy, String name, std::function<bool (GpuCommandBufferPool &)> taskWorker)

Methods

staticCreate

static SPtr<RendererTask> Create(String name, std::function<bool (GpuCommandBufferPool &)> taskWorker)

Creates a new task.

Task should be provided to Renderer in order for it to start.

name
Name you can use to more easily identify the task.
taskWorker
Worker method that does all of the work in the task. Tasks can run over the course of multiple frames, in which case this method should return false (if there's more work to be done), or true (if the task has completed).

IsComplete

bool IsComplete() const

Returns true if the task has completed.

IsCanceled

bool IsCanceled() const

Returns true if the task has been canceled.

Wait

void Wait()

Blocks the current thread until the task has completed.

Cancel

void Cancel()

Cancels the task and removes it from the Renderer's queue.

Fields

OnComplete

Event<void ()> OnComplete

Callback triggered on the main thread, when the task completes.

Is not triggered if the task is cancelled.

Private

Fields

mName

String mName

mTaskWorker

std::function<bool (GpuCommandBufferPool &)> mTaskWorker

mState

std::atomic<u32> mState

0 - Inactive, 1 - In progress, 2 - Completed, 3 - Canceled