Drag[en]gine Game Engine  1.21
deParallelProcessing Class Reference

Parallel task processing. More...

#include <deParallelProcessing.h>

Public Member Functions

Constructors and Destructors
 deParallelProcessing (deEngine &engine)
 Create parallel task processor. More...
 
 ~deParallelProcessing ()
 Clean up parallel task processor. More...
 
Management
deEngineGetEngine () const
 Game engine. More...
 
int GetCoreCount () const
 Count of detected CPU cores. More...
 
int GetThreadCount () const
 Count of threads. More...
 
void Update ()
 Update task processing. More...
 
bool GetPaused () const
 Parallel processing is paused. More...
 
void Pause ()
 Pause parallel processing. More...
 
void Resume ()
 Resume parallel processing. More...
 
void WaitForTask (deParallelTask *task)
 Wait for a task to finish. More...
 
void AddTask (deParallelTask *task)
 Wait for multiple tasks to finish. More...
 
void AddTaskAsync (deParallelTask *task)
 Add task to run the next time possible. More...
 
void FinishAndRemoveTasksOwnedBy (deBaseModule *module)
 Finish threads owned by module removing them from parallel processing. More...
 
void FinishAndRemoveAllTasks ()
 Finish all threads removing them from parallel processing. More...
 
deParallelThread Only
deParallelTaskNextPendingTask (bool takeLowPriorityTasks)
 Next pending task or NULL if there is none. More...
 
void WaitOnNewTasksSemaphore ()
 Wait on the new tasks semaphore. More...
 
void AddFinishedTask (deParallelTask *task)
 Add task to the list of finished tasks. More...
 

Debugging

bool GetOutputDebugMessages () const
 Debug messages are output to the engine logger. More...
 
void LogThreadAndTasks ()
 Log thread and task overview. More...
 

Detailed Description

Parallel task processing.

Constructor & Destructor Documentation

◆ deParallelProcessing()

deParallelProcessing::deParallelProcessing ( deEngine engine)

Create parallel task processor.

◆ ~deParallelProcessing()

deParallelProcessing::~deParallelProcessing ( )

Clean up parallel task processor.

Member Function Documentation

◆ AddFinishedTask()

void deParallelProcessing::AddFinishedTask ( deParallelTask task)

Add task to the list of finished tasks.

Warning
For use by deParallelTask only.

◆ AddTask()

void deParallelProcessing::AddTask ( deParallelTask task)

Wait for multiple tasks to finish.

Blocks until the tasks are finished.

Warning
Call only from the main thread! Never call from other threads!
Exceptions
deeInvalidActionParallel processing is paused.
deeInvalidParamtask is NULL.

Add task to run the next time possible.

Warning
Adding a task starts processing it immediately if a thread is ready. Add all dependencies before adding the task otherwise it can be run although the dependencies added later on are not finished.
Call only from the main thread! Never call from other threads!
Exceptions
deeInvalidParamtask is NULL.

◆ AddTaskAsync()

void deParallelProcessing::AddTaskAsync ( deParallelTask task)

Add task to run the next time possible.

Warning
Adding a task starts processing it immediately if a thread is ready. Add all dependencies before adding the task otherwise it can be run although the dependencies added later on are not finished.
Note
Safe to be called from all kinds of threads.
If parallel processing is paused the task is run immediately without being queued. This avoids synchronization issues.
Exceptions
deeInvalidParamtask is NULL.

◆ FinishAndRemoveAllTasks()

void deParallelProcessing::FinishAndRemoveAllTasks ( )

Finish all threads removing them from parallel processing.

To be called only by game engine during shut-down phase.

If a task is still pending it is first cancelled and waited for completion. This method has to be called to prevent accessing invalid memory if modules are unloaded for which tasks still exist. Cancelling the task is not enough since it stays in the list of finished tasks until finished.

◆ FinishAndRemoveTasksOwnedBy()

void deParallelProcessing::FinishAndRemoveTasksOwnedBy ( deBaseModule module)

Finish threads owned by module removing them from parallel processing.

To be called only by module systems during shut-down phase.

If a task is still pending it is first cancelled and waited for completion. This method has to be called to prevent accessing invalid memory if modules are unloaded for which tasks still exist. Cancelling the task is not enough since it stays in the list of finished tasks until finished.

◆ GetCoreCount()

int deParallelProcessing::GetCoreCount ( ) const
inline

Count of detected CPU cores.

◆ GetEngine()

deEngine& deParallelProcessing::GetEngine ( ) const
inline

Game engine.

◆ GetOutputDebugMessages()

bool deParallelProcessing::GetOutputDebugMessages ( ) const
inline

Debug messages are output to the engine logger.

◆ GetPaused()

bool deParallelProcessing::GetPaused ( ) const
inline

Parallel processing is paused.

All threads are waiting. It is safe to modify the game engine.

◆ GetThreadCount()

int deParallelProcessing::GetThreadCount ( ) const
inline

Count of threads.

◆ LogThreadAndTasks()

void deParallelProcessing::LogThreadAndTasks ( )

Log thread and task overview.

◆ NextPendingTask()

deParallelTask* deParallelProcessing::NextPendingTask ( bool  takeLowPriorityTasks)

Next pending task or NULL if there is none.

Warning
For use by deParallelTask only.

◆ Pause()

void deParallelProcessing::Pause ( )

Pause parallel processing.

Finishes running all threads and does not start new tasks. After this call returns All threads are waiting and it is safe to modify the game engine.

◆ Resume()

void deParallelProcessing::Resume ( )

Resume parallel processing.

Restarts all threads commencing processing tasks if any are pending.

◆ Update()

void deParallelProcessing::Update ( )

Update task processing.

Call once a frame to update tasks. Assigns tasks to waiting threads and promotes finished tasks to the finished queue. Called by the game engine before the scripting module does frame updates.

◆ WaitForTask()

void deParallelProcessing::WaitForTask ( deParallelTask task)

Wait for a task to finish.

Blocks until the task is finished.

Exceptions
deeInvalidActionParallel processing is paused.
deeInvalidParamtask is NULL.

◆ WaitOnNewTasksSemaphore()

void deParallelProcessing::WaitOnNewTasksSemaphore ( )

Wait on the new tasks semaphore.

Warning
For use by deParallelTask only.

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