TracktionEngine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
engine::RenderQueue Class Reference

Runs a list of render jobs strictly one at a time, in order. More...

#include <tracktion_RenderQueue.h>

Classes

class  Job
 A single job in the queue, obtained from addJob()/addJobs()/getJobs(). More...
 

Public Types

using JobPtr = std::shared_ptr< Job >
 

Public Member Functions

 RenderQueue ()=default
 
 ~RenderQueue ()
 Destructor.
 
JobPtr addJob (PlannedRenderJob)
 Adds a job to the queue, returning its handle.
 
void addJobs (std::vector< PlannedRenderJob >)
 Adds a list of jobs to the queue.
 
void start ()
 Starts running the queued jobs in order.
 
void cancelAll ()
 Cancels the active job and all pending jobs.
 
const std::vector< JobPtr > & getJobs () const
 Returns the jobs in the queue, in execution order.
 
bool hasStarted () const
 
bool hasFinished () const
 Returns true once every job has completed, failed or been cancelled.
 
float getTotalProgress () const
 Returns the overall progress of the queue, 0 to 1.
 

Public Attributes

std::function< void(Job &)> onJobStarted
 Called on the message thread as each job starts.
 
std::function< void(Job &)> onJobFinished
 Called on the message thread as each job finishes.
 
std::function< void()> onFinished
 Called on the message thread once all jobs have finished.
 

Detailed Description

Runs a list of render jobs strictly one at a time, in order.

Add jobs (usually from expandRenderSpecification()), keeping hold of the returned Job handles, attach any callbacks, then call start(). Each job renders on its own background thread via EditRenderer; the next job only starts once the previous one has finished. More jobs can be appended while the queue is running - call start() again after adding them in case the earlier jobs have already finished. All methods and callbacks are message-thread only.

Deleting the queue cancels any remaining jobs. Job handles remain valid after the queue has been deleted.

Member Typedef Documentation

◆ JobPtr

using engine::RenderQueue::JobPtr = std::shared_ptr<Job>

Constructor & Destructor Documentation

◆ RenderQueue()

engine::RenderQueue::RenderQueue ( )
default

◆ ~RenderQueue()

engine::RenderQueue::~RenderQueue ( )

Destructor.

Cancels any active and pending jobs.

Member Function Documentation

◆ addJob()

JobPtr engine::RenderQueue::addJob ( PlannedRenderJob  )

Adds a job to the queue, returning its handle.

Jobs may be appended at any time, including while the queue is running - call start() again afterwards in case the earlier jobs have already finished.

◆ addJobs()

void engine::RenderQueue::addJobs ( std::vector< PlannedRenderJob )

Adds a list of jobs to the queue.

◆ start()

void engine::RenderQueue::start ( )

Starts running the queued jobs in order.

Safe to call again after appending jobs to a running or finished queue: a no-op while a job is active, otherwise it picks up the next pending job. onFinished fires each time the queue runs out of pending jobs.

◆ cancelAll()

void engine::RenderQueue::cancelAll ( )

Cancels the active job and all pending jobs.

◆ getJobs()

const std::vector< JobPtr > & engine::RenderQueue::getJobs ( ) const

Returns the jobs in the queue, in execution order.

◆ hasStarted()

bool engine::RenderQueue::hasStarted ( ) const

◆ hasFinished()

bool engine::RenderQueue::hasFinished ( ) const

Returns true once every job has completed, failed or been cancelled.

◆ getTotalProgress()

float engine::RenderQueue::getTotalProgress ( ) const

Returns the overall progress of the queue, 0 to 1.

Member Data Documentation

◆ onJobStarted

std::function<void (Job&)> engine::RenderQueue::onJobStarted

Called on the message thread as each job starts.

◆ onJobFinished

std::function<void (Job&)> engine::RenderQueue::onJobFinished

Called on the message thread as each job finishes.

◆ onFinished

std::function<void()> engine::RenderQueue::onFinished

Called on the message thread once all jobs have finished.


The documentation for this class was generated from the following file: