2021-05-25 13:27:48 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "DerivedDataBuildScheduler.h"
|
|
|
|
|
|
|
|
|
|
#include "DerivedDataBuildFunction.h"
|
|
|
|
|
#include "DerivedDataBuildFunctionFactory.h"
|
|
|
|
|
#include "DerivedDataBuildFunctionRegistry.h"
|
2021-08-06 15:50:00 -04:00
|
|
|
#include "DerivedDataRequest.h"
|
|
|
|
|
#include "DerivedDataRequestOwner.h"
|
2021-05-25 13:27:48 -04:00
|
|
|
#include "Misc/Guid.h"
|
2021-07-16 01:25:15 -04:00
|
|
|
#include "Tasks/Task.h"
|
2021-05-25 13:27:48 -04:00
|
|
|
|
|
|
|
|
namespace UE::DerivedData::Private
|
|
|
|
|
{
|
|
|
|
|
|
2021-08-04 18:08:50 -04:00
|
|
|
class FBuildSchedulerRequest : public FRequestBase
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FBuildSchedulerRequest(IBuildJob* InJob, IRequestOwner& InOwner, const TCHAR* DebugName)
|
|
|
|
|
: Job(InJob)
|
|
|
|
|
, Owner(InOwner)
|
|
|
|
|
{
|
|
|
|
|
Tasks::FTaskEvent TaskEvent(TEXT("FBuildSchedulerRequest"));
|
|
|
|
|
Task = Tasks::Launch(DebugName, [this] { Schedule(); }, TaskEvent, Tasks::ETaskPriority::BackgroundNormal);
|
|
|
|
|
Owner.Begin(this);
|
|
|
|
|
TaskEvent.Trigger();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Schedule()
|
|
|
|
|
{
|
|
|
|
|
Owner.End(this, [this] { Job->Schedule(); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetPriority(EPriority Priority) final
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cancel() final
|
|
|
|
|
{
|
|
|
|
|
Task.Wait();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Wait() final
|
|
|
|
|
{
|
|
|
|
|
Task.Wait();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
IBuildJob* Job;
|
|
|
|
|
IRequestOwner& Owner;
|
|
|
|
|
Tasks::FTask Task;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-25 13:27:48 -04:00
|
|
|
class FBuildScheduler final : public IBuildScheduler
|
|
|
|
|
{
|
2021-07-16 01:25:15 -04:00
|
|
|
public:
|
2021-08-04 18:08:50 -04:00
|
|
|
void DispatchCacheQuery(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params) final;
|
|
|
|
|
void DispatchCacheStore(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params) final;
|
|
|
|
|
void DispatchResolveKey(IBuildJob* Job, IRequestOwner& Owner) final;
|
|
|
|
|
void DispatchResolveInputMeta(IBuildJob* Job, IRequestOwner& Owner) final;
|
|
|
|
|
void DispatchResolveInputData(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params) final;
|
|
|
|
|
void DispatchExecuteRemote(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params) final;
|
|
|
|
|
void DispatchExecuteLocal(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params) final;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void Dispatch(IBuildJob* Job, IRequestOwner& Owner, const TCHAR* DebugName);
|
2021-05-25 13:27:48 -04:00
|
|
|
};
|
|
|
|
|
|
2021-08-04 18:08:50 -04:00
|
|
|
void FBuildScheduler::DispatchCacheQuery(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params)
|
2021-07-16 01:25:15 -04:00
|
|
|
{
|
|
|
|
|
Job->Schedule();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-04 18:08:50 -04:00
|
|
|
void FBuildScheduler::DispatchCacheStore(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params)
|
2021-07-16 01:25:15 -04:00
|
|
|
{
|
|
|
|
|
Job->Schedule();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-04 18:08:50 -04:00
|
|
|
void FBuildScheduler::DispatchResolveKey(IBuildJob* Job, IRequestOwner& Owner)
|
2021-07-16 01:25:15 -04:00
|
|
|
{
|
2021-08-04 18:08:50 -04:00
|
|
|
Dispatch(Job, Owner, TEXT("FBuildScheduler::DispatchResolveKey"));
|
2021-07-16 01:25:15 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-04 18:08:50 -04:00
|
|
|
void FBuildScheduler::DispatchResolveInputMeta(IBuildJob* Job, IRequestOwner& Owner)
|
2021-07-16 01:25:15 -04:00
|
|
|
{
|
2021-08-04 18:08:50 -04:00
|
|
|
Dispatch(Job, Owner, TEXT("FBuildScheduler::DispatchResolveInputMeta"));
|
2021-07-16 01:25:15 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-04 18:08:50 -04:00
|
|
|
void FBuildScheduler::DispatchResolveInputData(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params)
|
2021-07-16 01:25:15 -04:00
|
|
|
{
|
2021-08-04 18:08:50 -04:00
|
|
|
Dispatch(Job, Owner, TEXT("FBuildScheduler::DispatchResolveInputData"));
|
2021-07-16 01:25:15 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-04 18:08:50 -04:00
|
|
|
void FBuildScheduler::DispatchExecuteRemote(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params)
|
2021-07-16 01:25:15 -04:00
|
|
|
{
|
2021-08-04 18:08:50 -04:00
|
|
|
Dispatch(Job, Owner, TEXT("FBuildScheduler::DispatchExecuteRemote"));
|
2021-07-16 01:25:15 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-04 18:08:50 -04:00
|
|
|
void FBuildScheduler::DispatchExecuteLocal(IBuildJob* Job, IRequestOwner& Owner, const FBuildSchedulerParams& Params)
|
2021-07-16 01:25:15 -04:00
|
|
|
{
|
2021-08-04 18:08:50 -04:00
|
|
|
Dispatch(Job, Owner, TEXT("FBuildScheduler::DispatchExecuteLocal"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FBuildScheduler::Dispatch(IBuildJob* Job, IRequestOwner& Owner, const TCHAR* DebugName)
|
|
|
|
|
{
|
|
|
|
|
if (Owner.GetPriority() == EPriority::Blocking)
|
2021-07-16 01:25:15 -04:00
|
|
|
{
|
|
|
|
|
Job->Schedule();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-08-04 18:08:50 -04:00
|
|
|
new FBuildSchedulerRequest(Job, Owner, DebugName);
|
2021-07-16 01:25:15 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-25 13:27:48 -04:00
|
|
|
IBuildScheduler* CreateBuildScheduler()
|
|
|
|
|
{
|
|
|
|
|
return new FBuildScheduler();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // UE::DerivedData::Private
|