Files
Per Larsson 682d39ed7e COTF2 - refactored package store synchronization to handle Begin/End lock
#rb CarlMagnus.Nordin
#jira UE-158341
#preflight 631076dbe54ec9d581cec8dc

[CL 21738832 by Per Larsson in ue5-main branch]
2022-09-01 08:57:12 -04:00

71 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#if WITH_COTF
#include "IO/PackageStore.h"
#include "CookOnTheFly.h"
#include "Misc/ScopeRWLock.h"
class FCookOnTheFlyPackageStoreBackend final
: public IPackageStoreBackend
{
public:
struct FEntryInfo
{
EPackageStoreEntryStatus Status = EPackageStoreEntryStatus::None;
int32 EntryIndex = INDEX_NONE;
};
struct FPackageStats
{
TAtomic<uint32> Cooked{ 0 };
TAtomic<uint32> Failed{ 0 };
};
FCookOnTheFlyPackageStoreBackend(UE::Cook::ICookOnTheFlyServerConnection& InCookOnTheFlyServerConnection);
virtual void OnMounted(TSharedRef<const FPackageStoreBackendContext> InContext) override
{
Context = InContext;
}
virtual void BeginRead() override;
virtual void EndRead() override;
bool DoesPackageExist(FPackageId PackageId);
virtual EPackageStoreEntryStatus GetPackageStoreEntry(FPackageId PackageId, FPackageStoreEntry& OutPackageStoreEntry) override;
virtual bool GetPackageRedirectInfo(FPackageId PackageId, FName& OutSourcePackageName, FPackageId& OutRedirectedToPackageId) override
{
return false;
}
private:
void SendCookRequest(TArray<FPackageId> PackageIds);
EPackageStoreEntryStatus CreatePackageStoreEntry(const FEntryInfo& EntryInfo, FPackageStoreEntry& OutPackageStoreEntry);
void AddPackages(TArray<FPackageStoreEntryResource> Entries, TArray<FPackageId> FailedPackageIds);
void OnCookOnTheFlyMessage(const UE::Cook::FCookOnTheFlyMessage& Message);
void CheckActivity();
UE::Cook::ICookOnTheFlyServerConnection& CookOnTheFlyServerConnection;
TSharedPtr<const FPackageStoreBackendContext> Context;
FRWLock EntriesLock;
TMap<FPackageId, FEntryInfo> PackageIdToEntryInfo;
TChunkedArray<FPackageStoreEntryResource> PackageEntries;
TArray<FPackageId> RequestedPackageIds;
FPackageStats PackageStats;
const double MaxInactivityTime = 20;
const double TimeBetweenWarning = 10;
double LastClientActivtyTime = 0;
double LastServerActivtyTime = 0;
double LastWarningTime = 0;
};
#endif // WITH_COTF