Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FAsyncWriter Class Reference

#include <OutputDeviceFile.h>

+ Inheritance diagram for FAsyncWriter:
+ Collaboration diagram for FAsyncWriter:

Public Types

enum class  EThreadNameOption : uint8 { FileName , Sequential }
 

Public Member Functions

 FAsyncWriter (FArchive &InAr, FAsyncWriter::EThreadNameOption NameOption=FAsyncWriter::EThreadNameOption::FileName)
 
virtual ~FAsyncWriter ()
 
virtual void Serialize (void *InData, int64 Length) override
 
void Flush ()
 
virtual bool Init ()
 
virtual uint32 Run ()
 
virtual void Stop ()
 
virtual FSingleThreadRunnableGetSingleThreadInterface () override
 
- Public Member Functions inherited from FRunnable
virtual void Exit ()
 
virtual ~FRunnable ()
 
- Public Member Functions inherited from FSingleThreadRunnable
virtual ~FSingleThreadRunnable ()
 
- Public Member Functions inherited from FArchive
 FArchive ()=default
 
 FArchive (const FArchive &)=default
 
FArchiveoperator= (const FArchive &ArchiveToCopy)=default
 
 ~FArchive ()=default
 
virtual FArchiveoperator<< (FName &Value)
 
virtual FArchiveoperator<< (FText &Value)
 
virtual FArchiveoperator<< (UObject *&Value)
 
virtual FArchiveoperator<< (FField *&Value)
 
template<class T >
FORCEINLINE FArchiveoperator<< (TCheckedObjPtr< T > &Value)
 
virtual FArchiveoperator<< (struct FLazyObjectPtr &Value)
 
virtual FArchiveoperator<< (struct FObjectPtr &Value)
 
virtual FArchiveoperator<< (struct FSoftObjectPtr &Value)
 
virtual FArchiveoperator<< (struct FSoftObjectPath &Value)
 
virtual FArchiveoperator<< (struct FWeakObjectPtr &Value)
 
virtual void ForceBlueprintFinalization ()
 
virtual void SerializeBits (void *V, int64 LengthBits)
 
virtual void SerializeInt (uint32 &Value, uint32 Max)
 
virtual void SerializeIntPacked (uint32 &Value)
 
virtual void Preload (UObject *Object)
 
FArchiveStateGetArchiveState ()
 
const FArchiveStateGetArchiveState () const
 
virtual void Seek (int64 InPos)
 
virtual void AttachBulkData (UObject *Owner, FBulkData *BulkData)
 
virtual void AttachBulkData (UE::Serialization::FEditorBulkData *BulkData)
 
virtual void DetachBulkData (FBulkData *BulkData, bool bEnsureBulkDataIsLoaded)
 
virtual void DetachBulkData (UE::Serialization::FEditorBulkData *BulkData, bool bEnsureBulkDataIsLoaded)
 
virtual bool SerializeBulkData (FBulkData &BulkData, const struct FBulkDataSerializationParams &Params)
 
virtual bool IsProxyOf (FArchive *InOther) const
 
virtual bool Precache (int64 PrecacheOffset, int64 PrecacheSize)
 
virtual void FlushCache ()
 
virtual bool SetCompressionMap (TArray< struct FCompressedChunk > *CompressedChunks, ECompressionFlags CompressionFlags)
 
virtual bool Close ()
 
void SerializeCompressed (void *V, int64 Length, FName CompressionFormatCannotChange, ECompressionFlags Flags=COMPRESS_NoFlags, bool bTreatBufferAsFileReader=false)
 
void SerializeCompressedNew (void *V, int64 Length, FName CompressionFormatToEncode, FName CompressionFormatToDecodeOldV1Files, ECompressionFlags Flags=COMPRESS_NoFlags, bool bTreatBufferAsFileReader=false, int64 *OutPartialReadLength=nullptr)
 
void SerializeCompressedNew (void *V, int64 Length)
 
void ByteSwap (void *V, int32 Length)
 
FORCEINLINE FArchiveByteOrderSerialize (void *V, int32 Length)
 
void StartSerializingDefaults ()
 
void StopSerializingDefaults ()
 
virtual void MarkScriptSerializationStart (const UObject *Obj)
 
virtual void MarkScriptSerializationEnd (const UObject *Obj)
 
virtual void MarkSearchableName (const UObject *TypeObject, const FName &ValueName) const
 
template<typename FmtType , typename... Types>
void Logf (const FmtType &Fmt, Types... Args)
 
virtual void UsingCustomVersion (const struct FGuid &Guid)
 
virtual FArchiveGetCacheableArchive ()
 
virtual void PushSerializedProperty (struct FProperty *InProperty, const bool bIsEditorOnlyProperty)
 
virtual void PopSerializedProperty (struct FProperty *InProperty, const bool bIsEditorOnlyProperty)
 
virtual bool AttachExternalReadDependency (FExternalReadCallback &ReadCallback)
 
template<SIZE_T Size>
FORCEINLINE bool FastPathLoad (void *InDest)
 
virtual void PushFileRegionType (EFileRegionType Type)
 
virtual void PopFileRegionType ()
 
void SetArchiveState (const FArchiveState &InState)
 
void SetError ()
 
void ClearError ()
 
virtual FArchiveStateGetInnermostState ()
 
virtual void CountBytes (SIZE_T InNum, SIZE_T InMax)
 
virtual FString GetArchiveName () const
 
virtual FLinkerGetLinker ()
 
virtual int64 Tell ()
 
virtual int64 TotalSize ()
 
virtual bool AtEnd ()
 
FORCEINLINE bool IsByteSwapping ()
 
void ThisContainsCode ()
 
void ThisContainsMap ()
 
void ThisRequiresLocalizationGather ()
 
virtual UObjectGetArchetypeFromLoader (const UObject *Obj)
 
FORCEINLINE FPackageFileVersion UEVer () const
 
FORCEINLINE int32 UE4Ver () const
 
FORCEINLINE int32 LicenseeUEVer () const
 
FORCEINLINE FEngineVersionBase EngineVer () const
 
uint32 EngineNetVer () const
 
uint32 GameNetVer () const
 
int32 CustomVer (const struct FGuid &Key) const
 
FORCEINLINE bool IsLoading () const
 
FORCEINLINE bool IsLoadingFromCookedPackage () const
 
FORCEINLINE bool IsSaving () const
 
FORCEINLINE bool IsTransacting () const
 
FORCEINLINE bool IsTextFormat () const
 
FORCEINLINE bool WantBinaryPropertySerialization () const
 
FORCEINLINE bool UseUnversionedPropertySerialization () const
 
FORCEINLINE bool IsForcingUnicode () const
 
FORCEINLINE bool IsPersistent () const
 
FORCEINLINE bool GetError () const
 
FORCEINLINE bool IsError () const
 
FORCEINLINE bool IsCriticalError () const
 
FORCEINLINE bool ContainsCode () const
 
FORCEINLINE bool ContainsMap () const
 
FORCEINLINE bool RequiresLocalizationGather () const
 
FORCEINLINE bool ForceByteSwapping () const
 
FORCEINLINE bool IsSerializingDefaults () const
 
FORCEINLINE bool IsIgnoringArchetypeRef () const
 
FORCEINLINE bool DoDelta () const
 
FORCEINLINE bool DoIntraPropertyDelta () const
 
FORCEINLINE bool IsIgnoringOuterRef () const
 
FORCEINLINE bool IsIgnoringClassGeneratedByRef () const
 
FORCEINLINE bool IsIgnoringClassRef () const
 
FORCEINLINE bool IsAllowingLazyLoading () const
 
FORCEINLINE bool IsObjectReferenceCollector () const
 
FORCEINLINE bool IsModifyingWeakAndStrongReferences () const
 
FORCEINLINE bool IsCountingMemory () const
 
FORCEINLINE uint32 GetPortFlags () const
 
FORCEINLINE bool HasAnyPortFlags (uint32 Flags) const
 
FORCEINLINE bool HasAllPortFlags (uint32 Flags) const
 
FORCEINLINE uint32 GetDebugSerializationFlags () const
 
FORCEINLINE bool ShouldSkipBulkData () const
 
FORCEINLINE int64 GetMaxSerializeSize () const
 
virtual const FCustomVersionContainerGetCustomVersions () const
 
virtual void SetCustomVersions (const FCustomVersionContainer &CustomVersionContainer)
 
virtual void ResetCustomVersions ()
 
void SetCustomVersion (const struct FGuid &Key, int32 Version, FName FriendlyName)
 
void SetByteSwapping (bool Enabled)
 
void SetPortFlags (uint32 InPortFlags)
 
void SetDebugSerializationFlags (uint32 InCustomFlags)
 
bool IsFilterEditorOnly () const
 
virtual void SetFilterEditorOnly (bool InFilterEditorOnly)
 
bool IsSaveGame () const
 
FORCEINLINE bool IsNetArchive () const
 
FORCEINLINE bool IsCooking () const
 
FORCEINLINE const ITargetPlatformCookingTarget () const
 
void SetCookData (FArchiveCookData *InCookData)
 
FArchiveCookDataGetCookData ()
 
FORCEINLINE FArchiveCookContextGetCookContext ()
 
virtual bool UseToResolveEnumerators () const
 
virtual bool ShouldSkipProperty (const FProperty *InProperty) const
 
virtual void SetSerializedProperty (FProperty *InProperty)
 
FORCEINLINE struct FPropertyGetSerializedProperty () const
 
void GetSerializedPropertyChain (TArray< struct FProperty * > &OutProperties) const
 
FORCEINLINE const FArchiveSerializedPropertyChainGetSerializedPropertyChain () const
 
virtual void SetSerializedPropertyChain (const FArchiveSerializedPropertyChain *InSerializedPropertyChain, struct FProperty *InSerializedPropertyOverride=nullptr)
 
virtual void SetSerializeContext (FUObjectSerializeContext *InLoadContext)
 
virtual FUObjectSerializeContextGetSerializeContext ()
 
virtual void Reset ()
 
virtual void SetIsLoading (bool bInIsLoading)
 
virtual void SetIsLoadingFromCookedPackage (bool bInIsLoadingFromCookedPackage)
 
virtual void SetIsSaving (bool bInIsSaving)
 
virtual void SetIsTransacting (bool bInIsTransacting)
 
virtual void SetIsTextFormat (bool bInIsTextFormat)
 
virtual void SetWantBinaryPropertySerialization (bool bInWantBinaryPropertySerialization)
 
virtual void SetUseUnversionedPropertySerialization (bool bInUseUnversioned)
 
virtual void SetForceUnicode (bool bInForceUnicode)
 
virtual void SetIsPersistent (bool bInIsPersistent)
 
virtual void SetUEVer (FPackageFileVersion InVer)
 
FORCEINLINE void SetUE4Ver (int32 InVer)
 
virtual void SetLicenseeUEVer (int32 InVer)
 
virtual void SetEngineVer (const FEngineVersionBase &InVer)
 
virtual void SetEngineNetVer (const uint32 InEngineNetVer)
 
virtual void SetGameNetVer (const uint32 InGameNetVer)
 
FORCEINLINE bool ShouldSkipCompilingAssets () const
 

Protected Member Functions

virtual void Tick () override
 
- Protected Member Functions inherited from FArchive
void SetShouldSkipCompilingAssets (bool Enabled)
 

Private Types

enum  EConstants { InitialBufferSize = 128 * 1024 }
 

Private Member Functions

void FlushArchiveAndResetTimer ()
 
void SerializeBufferToArchive ()
 
void FlushBuffer ()
 

Private Attributes

volatile FRunnableThreadThread
 
FThreadSafeCounter StopTaskCounter
 
FArchiveAr
 
TArray< uint8Buffer
 
TAtomic< int32BufferStartPos
 
TAtomic< int32BufferEndPos
 
FCriticalSection BufferPosCritical
 
FThreadSafeCounter SerializeRequestCounter
 
FThreadSafeCounter WantsArchiveFlush
 
FCriticalSection RunCritical
 
double LastArchiveFlushTime
 

Additional Inherited Members

- Public Attributes inherited from FArchive
FFastPathLoadBufferActiveFPLB
 
FFastPathLoadBuffer InlineFPLB
 
uint8 ArContainsCode: 1
 
uint8 ArContainsMap: 1
 
uint8 ArRequiresLocalizationGather: 1
 
uint8 ArForceByteSwapping: 1
 
uint8 ArIgnoreArchetypeRef: 1
 
uint8 ArNoDelta: 1
 
uint8 ArNoIntraPropertyDelta: 1
 
uint8 ArIgnoreOuterRef: 1
 
uint8 ArIgnoreClassGeneratedByRef: 1
 
uint8 ArIgnoreClassRef: 1
 
uint8 ArAllowLazyLoading: 1
 
uint8 ArIsObjectReferenceCollector: 1
 
uint8 ArIsModifyingWeakAndStrongReferences: 1
 
uint8 ArIsCountingMemory: 1
 
uint8 ArShouldSkipBulkData: 1
 
uint8 ArIsFilterEditorOnly: 1
 
uint8 ArIsSaveGame: 1
 
uint8 ArIsNetArchive: 1
 
uint8 ArUseCustomPropertyList: 1
 
int32 ArSerializingDefaults
 
uint32 ArPortFlags
 
int64 ArMaxSerializeSize
 
const struct FCustomPropertyListNodeArCustomPropertyList
 
- Static Protected Member Functions inherited from FArchive
static void LinkProxy (FArchiveState &Inner, FArchiveState &Proxy)
 
static void UnlinkProxy (FArchiveState &Inner, FArchiveState &Proxy)
 

Detailed Description

Provides a thread-safe serialization interface with a background thread doing the actual writes. [] tags identify which thread owns a variable or function

Definition at line 30 of file OutputDeviceFile.h.

Member Enumeration Documentation

◆ EConstants

Enumerator
InitialBufferSize 

Definition at line 32 of file OutputDeviceFile.h.

◆ EThreadNameOption

Enumerator
FileName 
Sequential 

Definition at line 73 of file OutputDeviceFile.h.

Constructor & Destructor Documentation

◆ FAsyncWriter()

FAsyncWriter::FAsyncWriter ( FArchive & InAr,
FAsyncWriter::EThreadNameOption NameOption = FAsyncWriter::EThreadNameOption::FileName )

◆ ~FAsyncWriter()

virtual FAsyncWriter::~FAsyncWriter ( )
virtual

Member Function Documentation

◆ Flush()

void FAsyncWriter::Flush ( )
virtual

Flush all buffers to disk

Reimplemented from FArchive.

◆ FlushArchiveAndResetTimer()

void FAsyncWriter::FlushArchiveAndResetTimer ( )
private

[WRITER THREAD] Flushes the archive and reset the flush timer.

◆ FlushBuffer()

void FAsyncWriter::FlushBuffer ( )
private

[CLIENT THREAD] Flush the memory buffer (doesn't force the archive to flush). Can only be used from inside of BufferPosCritical lock.

◆ GetSingleThreadInterface()

virtual FSingleThreadRunnable * FAsyncWriter::GetSingleThreadInterface ( )
inlineoverridevirtual

Gets single thread interface pointer used for ticking this runnable when multi-threading is disabled. If the interface is not implemented, this runnable will not be ticked when FPlatformProcess::SupportsMultithreading() is false.

Returns
Pointer to the single thread interface or nullptr if not implemented.

Reimplemented from FRunnable.

Definition at line 93 of file OutputDeviceFile.h.

◆ Init()

virtual bool FAsyncWriter::Init ( )
virtual

Initializes the runnable object.

This method is called in the context of the thread object that aggregates this, not the thread that passes this runnable to a new thread.

Returns
True if initialization was successful, false otherwise
See also
Run, Stop, Exit

Reimplemented from FRunnable.

◆ Run()

virtual uint32 FAsyncWriter::Run ( )
virtual

Runs the runnable object.

This is where all per object thread work is done. This is only called if the initialization was successful.

Returns
The exit code of the runnable object
See also
Init, Stop, Exit

Implements FRunnable.

◆ Serialize()

virtual void FAsyncWriter::Serialize ( void * InData,
int64 Length )
overridevirtual

[CLIENT THREAD] Serialize data to buffer that will later be saved to disk by the async thread

Reimplemented from FArchive.

◆ SerializeBufferToArchive()

void FAsyncWriter::SerializeBufferToArchive ( )
private

[WRITER THREAD] Serialize the contents of the ring buffer to disk

◆ Stop()

virtual void FAsyncWriter::Stop ( )
virtual

Stops the runnable object.

This is called if a thread is requested to terminate early.

See also
Init, Run, Exit

Reimplemented from FRunnable.

◆ Tick()

virtual void FAsyncWriter::Tick ( )
overrideprotectedvirtual

[CLIENT THREAD] A substitute for Run() for when threading is disabled.

Implements FSingleThreadRunnable.

Member Data Documentation

◆ Ar

FArchive& FAsyncWriter::Ar
private

Writer archive

Definition at line 43 of file OutputDeviceFile.h.

◆ Buffer

TArray<uint8> FAsyncWriter::Buffer
private

Data ring buffer

Definition at line 45 of file OutputDeviceFile.h.

◆ BufferEndPos

TAtomic<int32> FAsyncWriter::BufferEndPos
private

[CLIENT THREAD] Position where the unserialized data ends in the buffer (such as if (BufferEndPos > BufferStartPos) Length = BufferEndPos - BufferStartPos;

Definition at line 49 of file OutputDeviceFile.h.

◆ BufferPosCritical

FCriticalSection FAsyncWriter::BufferPosCritical
private

[CLIENT THREAD] Sync object for the buffer pos

Definition at line 51 of file OutputDeviceFile.h.

◆ BufferStartPos

TAtomic<int32> FAsyncWriter::BufferStartPos
private

[WRITER THREAD] Position where the unserialized data starts in the buffer

Definition at line 47 of file OutputDeviceFile.h.

◆ LastArchiveFlushTime

double FAsyncWriter::LastArchiveFlushTime
private

[WRITER THREAD] Last time the archive was flushed. used in threaded situations to flush the underlying archive at a certain maximum rate.

Definition at line 60 of file OutputDeviceFile.h.

◆ RunCritical

FCriticalSection FAsyncWriter::RunCritical
private

Sync object for buffer flushes in forkable mode, when forking hasn't occurred yet.

Definition at line 57 of file OutputDeviceFile.h.

◆ SerializeRequestCounter

FThreadSafeCounter FAsyncWriter::SerializeRequestCounter
private

[CLIENT/WRITER THREAD] Outstanding serialize request counter. This is to make sure we flush all requests.

Definition at line 53 of file OutputDeviceFile.h.

◆ StopTaskCounter

FThreadSafeCounter FAsyncWriter::StopTaskCounter
private

Stops this thread

Definition at line 40 of file OutputDeviceFile.h.

◆ Thread

volatile FRunnableThread* FAsyncWriter::Thread
private

Thread to run the worker FRunnable on. Serializes the ring buffer to disk.

Definition at line 38 of file OutputDeviceFile.h.

◆ WantsArchiveFlush

FThreadSafeCounter FAsyncWriter::WantsArchiveFlush
private

[CLIENT/WRITER THREAD] Tells the writer thread, the client requested flush.

Definition at line 55 of file OutputDeviceFile.h.


The documentation for this class was generated from the following file: