Drag[en]gine Game Engine
1.21
|
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 | |
deEngine & | GetEngine () 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 | |
deParallelTask * | NextPendingTask (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... | |
Parallel task processing.
deParallelProcessing::deParallelProcessing | ( | deEngine & | engine | ) |
Create parallel task processor.
deParallelProcessing::~deParallelProcessing | ( | ) |
Clean up parallel task processor.
void deParallelProcessing::AddFinishedTask | ( | deParallelTask * | task | ) |
Add task to the list of finished tasks.
void deParallelProcessing::AddTask | ( | deParallelTask * | task | ) |
Wait for multiple tasks to finish.
Blocks until the tasks are finished.
deeInvalidAction | Parallel processing is paused. |
deeInvalidParam | task is NULL. |
Add task to run the next time possible.
deeInvalidParam | task is NULL. |
void deParallelProcessing::AddTaskAsync | ( | deParallelTask * | task | ) |
Add task to run the next time possible.
deeInvalidParam | task is NULL. |
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.
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.
|
inline |
Count of detected CPU cores.
|
inline |
Game engine.
|
inline |
Debug messages are output to the engine logger.
|
inline |
Parallel processing is paused.
All threads are waiting. It is safe to modify the game engine.
|
inline |
Count of threads.
void deParallelProcessing::LogThreadAndTasks | ( | ) |
Log thread and task overview.
deParallelTask* deParallelProcessing::NextPendingTask | ( | bool | takeLowPriorityTasks | ) |
Next pending task or NULL if there is none.
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.
void deParallelProcessing::Resume | ( | ) |
Resume parallel processing.
Restarts all threads commencing processing tasks if any are pending.
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.
void deParallelProcessing::WaitForTask | ( | deParallelTask * | task | ) |
Wait for a task to finish.
Blocks until the task is finished.
deeInvalidAction | Parallel processing is paused. |
deeInvalidParam | task is NULL. |
void deParallelProcessing::WaitOnNewTasksSemaphore | ( | ) |
Wait on the new tasks semaphore.