You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Add batched Put and PutValue. Update Batched Get to send the RecordPolicy with each key. Update GetChunks to send the CachePolicy as string and to handle SkipData in the response. Add more unit tests for upstream behavior and GetChunks. Update the CacheRecordPolicy Save/Load to match the new variable names on FCacheRecordPolicy. Deploy new zenserver binaries with the required matching server-side changes. #rb Per.Larsson,Devin.Doucette #rnx #preflight 61f94e5980608c7029b8fc5c #ROBOMERGE-AUTHOR: matt.peters #ROBOMERGE-SOURCE: CL 18808743 in //UE5/Release-5.0/... via CL 18809399 via CL 18822531 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545) [CL 18823289 by matt peters in ue5-main branch]
88 lines
2.1 KiB
C++
88 lines
2.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "Containers/Array.h"
|
|
#include "Containers/ArrayView.h"
|
|
#include "HAL/Platform.h"
|
|
#include "Misc/AssertionMacros.h"
|
|
|
|
enum class EBatchView
|
|
{
|
|
/** Add the item to the previous batch. If no previous batch, treated the same as NewBatch. */
|
|
Continue,
|
|
/** End the previous batch (if it exists), start a new batch, add the item to the new batch. */
|
|
NewBatch,
|
|
};
|
|
|
|
/**
|
|
* Takes a list of items and a ShouldAddToBatch function and provides
|
|
* a ranged-for over the set of batches created from the list.
|
|
*/
|
|
template <typename T>
|
|
class TBatchView
|
|
{
|
|
public:
|
|
/**
|
|
* Constructor from list of elements and a function that is called on each element
|
|
* to decide whether to add the element to the current batch.
|
|
*
|
|
* EBatchView ShouldAddToBatch(const T& Item);
|
|
*/
|
|
template <typename ShouldAddToBatchFunc>
|
|
TBatchView(TArrayView<T> InItems, ShouldAddToBatchFunc&& ShouldAddToBatch)
|
|
: Items(InItems)
|
|
{
|
|
if (Items.IsEmpty())
|
|
{
|
|
return;
|
|
}
|
|
ShouldAddToBatch(Items[0]);
|
|
BatchStarts.Add(0);
|
|
for (int32 Index = 1; Index < Items.Num(); ++Index)
|
|
{
|
|
if (ShouldAddToBatch(Items[Index]) == EBatchView::NewBatch)
|
|
{
|
|
BatchStarts.Add(Index);
|
|
}
|
|
}
|
|
}
|
|
|
|
struct TIterator
|
|
{
|
|
TIterator(const TBatchView& InBatchList, bool bEnd)
|
|
: BatchList(InBatchList)
|
|
, BatchIndex(bEnd ? BatchList.BatchStarts.Num() : 0)
|
|
{
|
|
}
|
|
TIterator& operator++()
|
|
{
|
|
BatchIndex++;
|
|
return *this;
|
|
}
|
|
TArrayView<T> operator*() const
|
|
{
|
|
int32 Start = BatchList.BatchStarts[BatchIndex];
|
|
int32 End = BatchIndex < BatchList.BatchStarts.Num() - 1 ? BatchList.BatchStarts[BatchIndex + 1] : BatchList.Items.Num();
|
|
return TArrayView<T>(BatchList.Items.GetData() + Start, End - Start);
|
|
}
|
|
bool operator!=(TIterator& Other) const
|
|
{
|
|
return BatchIndex != Other.BatchIndex;
|
|
}
|
|
const TBatchView& BatchList;
|
|
int32 BatchIndex;
|
|
};
|
|
TIterator begin() const
|
|
{
|
|
return TIterator(*this, false /* bEnd */);
|
|
}
|
|
TIterator end() const
|
|
{
|
|
return TIterator(*this, true /* bEnd */);
|
|
}
|
|
|
|
private:
|
|
TArrayView<T> Items;
|
|
TArray<int32> BatchStarts;
|
|
}; |