Files
UnrealEngineUWP/Engine/Source/Developer/DerivedDataCache/Public/DerivedDataBuildScheduler.h
Devin Doucette f64bc61bb7 DDC: Fixed race conditions in the build job
#rb Zousar.Shaker
#rnx

[CL 16870676 by Devin Doucette in ue5-main branch]
2021-07-16 01:11:20 -04:00

84 lines
3.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "DerivedDataBuildJob.h"
#include "DerivedDataBuildKey.h"
namespace UE::DerivedData { struct FBuildSchedulerParams; }
namespace UE::DerivedData
{
/**
* A build scheduler is responsible for deciding when and where a job executes in certain states.
*
* Jobs dispatch themselves to their scheduler when they are prepared to access limited resources
* such as: memory, compute, storage, network. A scheduler may allow a job to execute immediately
* or may queue it to execute later. A scheduler that uses a job queue is expected to execute the
* jobs in priority order, respecting updates to priority.
*/
class IBuildScheduler
{
public:
virtual ~IBuildScheduler() = default;
/** Begin processing of the job by this scheduler. Always paired with EndJob. */
virtual void BeginJob(IBuildJob* Job) {}
/** End processing of the job by this scheduler. Always paired with BeginJob. */
virtual void EndJob(IBuildJob* Job) {}
/** Dispatch the job immediately if it is queued. May be called multiple times and/or concurrently. */
virtual void CancelJob(IBuildJob* Job) {}
/** Update the priority of the job if it is queued. May be called multiple times and/or concurrently. */
virtual void UpdateJobPriority(IBuildJob* Job) {}
/** Dispatch by calling Schedule or SetOutput, either now or later. */
virtual void DispatchCacheQuery(IBuildJob* Job, const FBuildSchedulerParams& Params) { Job->Schedule(); }
/** Dispatch by calling Schedule, either now or later. */
virtual void DispatchCacheStore(IBuildJob* Job, const FBuildSchedulerParams& Params) { Job->Schedule(); }
/** Dispatch by calling Schedule, either now or later. */
virtual void DispatchResolveKey(IBuildJob* Job) { Job->Schedule(); }
/** Dispatch by calling Schedule, either now or later. */
virtual void DispatchResolveInputMeta(IBuildJob* Job) { Job->Schedule(); }
/**
* Dispatch by calling Schedule, SetOutput, or SkipExecuteRemote, either now or later.
*
* SkipExecuteRemote is only valid to call when MissingRemoteInputsSize is non-zero.
*/
virtual void DispatchResolveInputData(IBuildJob* Job, const FBuildSchedulerParams& Params) { Job->Schedule(); }
/** Dispatch by calling Schedule, SetOutput, or SkipExecuteRemote, either now or later. */
virtual void DispatchExecuteRemote(IBuildJob* Job, const FBuildSchedulerParams& Params) { Job->Schedule(); }
/** Dispatch by calling Schedule or SetOutput, either now or later. */
virtual void DispatchExecuteLocal(IBuildJob* Job, const FBuildSchedulerParams& Params) { Job->Schedule(); }
/** Set the output of the job. Always called once between BeginJob and EndJob unless canceled. */
virtual void SetJobOutput(IBuildJob* Job, const FBuildSchedulerParams& Params, const FBuildOutput& Output) {}
};
/** Parameters that describe a build job to the build scheduler. */
struct FBuildSchedulerParams
{
FBuildActionKey Key;
/** Total size of constants and inputs, whether resolved or not. */
uint64 TotalInputsSize = 0;
/** Total size of constants and resolved inputs that are in memory now. */
uint64 ResolvedInputsSize = 0;
/** Total size of inputs that need to be resolved for local execution. Available in ResolveInputData. */
uint64 MissingLocalInputsSize = 0;
/** Total size of inputs that need to be resolved for remote execution. Available in ResolveInputData. */
uint64 MissingRemoteInputsSize = 0;
};
} // UE::DerivedData