ezEngine  Release 25.03
ezTaskPriority Struct Reference

Describes the priority with which to execute a task. More...

#include <TaskSystemDeclarations.h>

Public Types

enum  Enum : ezUInt8 {
  EarlyThisFrame, ThisFrame, LateThisFrame, EarlyNextFrame,
  NextFrame, LateNextFrame, In2Frames, In3Frames,
  In4Frames, In5Frames, In6Frames, In7Frames,
  In8Frames, In9Frames, LongRunningHighPriority, LongRunning,
  FileAccessHighPriority, FileAccess, ThisFrameMainThread, SomeFrameMainThread,
  ENUM_COUNT
}
 

Detailed Description

Describes the priority with which to execute a task.

For tasks that you start this frame and that need to finish within the same frame, use 'EarlyThisFrame', 'ThisFrame' or 'LateThisFrame'.
However you should generally not rely on starting tasks in the same frame in which they need to finish.
Instead prefer to start a task, whose result you need in the next frame or even later.
For those tasks, use 'EarlyNextFrame', 'NextFrame', 'LateNextFrame' and 'InNFrames'.
Once 'ezTaskSystem::FinishFrameTasks' is called, all those tasks will be moved into the 'XYZThisFrame' categories.
For tasks that run over a longer period (e.g. path searches, procedural data creation), use 'LongRunning'. Only use 'LongRunningHighPriority' for tasks that occur rarely, otherwise 'LongRunning' tasks might not get processed, at all.
For tasks that need to access files, prefer to use 'FileAccess', this way all file accesses get executed sequentially.
Use 'FileAccessHighPriority' to get very important file accesses done sooner. For example writing out a save-game should finish quickly.
For tasks that need to execute on the main thread (e.g. uploading GPU resources) use 'ThisFrameMainThread' or 'SomeFrameMainThread' depending on how urgent it is. 'SomeFrameMainThread' tasks might get delayed for quite a while, depending on the system load. For tasks that need to do several things (e.g. reading from a file AND uploading something on the main thread), split them up into several tasks that depend on each other (or just let the first task start the next step once it is finished). There is no guarantee WHEN (within a frame) main thread tasks get executed. Most of them will get executed upon a 'FinishFrameTasks' call. However they are also run whenever the main thread needs to wait or cancel some other task and has nothing else to do. So tasks that get executed on the main thread should never assume a certain state of other systems.

Member Enumeration Documentation

◆ Enum

enum ezTaskPriority::Enum : ezUInt8
Enumerator
EarlyThisFrame 

Highest priority, guaranteed to get finished in this frame.

ThisFrame 

Medium priority, guaranteed to get finished in this frame.

LateThisFrame 

Low priority, guaranteed to get finished in this frame.

EarlyNextFrame 

Highest priority in next frame, guaranteed to get finished this frame or the next.

NextFrame 

Medium priority in next frame, guaranteed to get finished this frame or the next.

LateNextFrame 

Low priority in next frame, guaranteed to get finished this frame or the next.

In2Frames 

A short task that should be finished no later than in 2 frames.

In3Frames 

A short task that should be finished no later than in 3 frames.

In4Frames 

A short task that should be finished no later than in 4 frames.

In5Frames 

A short task that should be finished no later than in 5 frames.

In6Frames 

A short task that should be finished no later than in 6 frames.

In7Frames 

A short task that should be finished no later than in 7 frames.

In8Frames 

A short task that should be finished no later than in 8 frames.

In9Frames 

A short task that should be finished no later than in 9 frames.

LongRunningHighPriority 

Tasks that might take a while, but should be preferred over 'LongRunning' tasks. Use this priority only rarely, otherwise 'LongRunning' tasks might never get executed.

LongRunning 

Use this priority for tasks that might run for a while.

FileAccessHighPriority 

For tasks that require file access (e.g. resource loading). They run on one dedicated thread, such that file accesses are done sequentially and never in parallel.

FileAccess 

For tasks that require file access (e.g. resource loading). They run on one dedicated thread, such that file accesses are done sequentially and never in parallel.

ThisFrameMainThread 

Tasks that need to be executed this frame, but in the main thread. This is mostly intended for resource creation.

SomeFrameMainThread 

Tasks that have no hard deadline but need to be executed in the main thread. This is mostly intended for resource creation.


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