Add JobSystem::Dispatch that accepts dependent jobs that needs to be completed before

This commit is contained in:
Wojtek Figat
2024-06-24 13:12:48 +02:00
parent 2773949197
commit 861d8a683f
2 changed files with 119 additions and 24 deletions

View File

@@ -4,6 +4,9 @@
#include "Engine/Core/Delegate.h"
template<typename T>
class Span;
/// <summary>
/// Lightweight multi-threaded jobs execution scheduler. Uses a pool of threads and supports work-stealing concept.
/// </summary>
@@ -26,6 +29,15 @@ API_CLASS(Static) class FLAXENGINE_API JobSystem
/// <returns>The label identifying this dispatch. Can be used to wait for the execution end.</returns>
API_FUNCTION() static int64 Dispatch(const Function<void(int32)>& job, int32 jobCount = 1);
/// <summary>
/// Dispatches the job for the execution after all of dependant jobs will complete.
/// </summary>
/// <param name="job">The job. Argument is an index of the job execution.</param>
/// <param name="dependencies">The list of dependant jobs that need to complete in order to start executing this job.</param>
/// <param name="jobCount">The job executions count.</param>
/// <returns>The label identifying this dispatch. Can be used to wait for the execution end.</returns>
API_FUNCTION() static int64 Dispatch(const Function<void(int32)>& job, Span<int64> dependencies, int32 jobCount = 1);
/// <summary>
/// Waits for all dispatched jobs to finish.
/// </summary>