Choose your operating system:
Windows
macOS
Linux
| FArchiveState
|
Module |
|
Header |
/Engine/Source/Runtime/Core/Public/Misc/PreloadableFile.h |
Include |
#include "Misc/PreloadableFile.h" |
class FPreloadableArchive : public FArchive
A read-only archive that adds support for asynchronous preloading and priming to an inner archive.
This class supports two mutually-exclusive modes: PreloadBytes: An asynchronous inner archive is opened using the passed-in CreateAsyncArchive function; this call is made asynchronously on a TaskGraph thread. The size is read during initialization. After initialization, when StartPreload is called, an array of bytes equal in size to the inner archive's size is allocated, and an asynchronous ReadRequest is sent to the IAsyncReadFileHandle to read the first <PageSize> bytes of the file. Upon completion of each in-flight ReadRequest, another asynchronous ReadRequest is issued, until the entire file has been read. If serialize functions are called beyond the bytes of the file that have been cached so far, they requests are satisfied by synchronous reads.
Activate this mode by passing an FCreateArchive to InitializeAsync. PreloadHandle: A synchronous inner archive is opened using the passed-in CreateArchive function; this call is made asynchronously on a TaskGraph thread. Optionally, a precache request is sent to the inner archive for the first <PrimeSize> bytes; this call is also made asynchronously. The created and primed lower-level FArchive can then be detached from this class and handed off to a new owner.
Activate this mode by passing an FCreateAsyncArchive and (optionally, for the precache request) Flags::Prime to InitializeAsync.
This class is not threadsafe. The public interface can be used at the same time as internal asynchronous tasks are executing, but the public interface can not be used from multiple threads at once.
Name | Description | ||
---|---|---|---|
|
ArchiveName |
||
|
TUniquePtr< IAs... |
AsynchronousHandle |
The handle used for PreloadBytes mode, to fulfull ReadReqeusts. |
|
bInitialized |
Threadsafe variable that returns true only after all asynchronous initialization is complete. |
|
|
bIsInlineReadComplete |
Set to true during the ReadRequest call to allow us to detect if OnReadComplete is called inline on the same thread from ReadRequest. |
|
|
bIsPreloading |
Threadsafe variable that is true only during the period between initialization until Preloading stops (either due to EOF reached or due to Serialize turning it off. |
|
|
bIsPreloadingPaused |
Variable that is set to true from the public interface thread to signal that (temporarily) no further ReadRequests should be sent when the currently active one completes. |
|
|
bReadCompleteWasCalledInline |
Set to true if OnReadComplete is called inline on the same thread from ReadRequest; we need special handling for this case. |
|
|
uint8 * |
CacheBytes |
An array of bytes of size Size. |
|
CacheEnd |
Number of bytes in CacheBytes that have already been read. |
|
|
PageSize |
The number of bytes requested from the AsynchronousHandle in each ReadRequest. |
|
|
FEvent * |
PendingAsyncComplete |
An Event used for synchronization with asynchronous tasks - InitializingAsync or receiving ReadRequests from the AsynchronousHandle. |
|
Pos |
The Offset into the file or preloaded bytes that will be used in the next call to Serialize. |
|
|
PreloadLock |
CriticalSection used to synchronize access to the CacheBytes. |
|
|
RetiredRequests |
ReadRequests that have completed but we have not yet deleted. |
|
|
SavedReadCompleteArguments |
||
|
Size |
The number of bytes in the file. |
|
|
TUniquePtr< FAr... |
SynchronousArchive |
The archive used in PreloadHandle mode or to service Serialize requests that are beyond CacheEnd when in PreloadBytes mode. |
Name | Description | |
---|---|---|
|
FPreloadableArchive ( |
Name | Description | |
---|---|---|
|
~FPreloadableArchive() |
Name | Description | ||
---|---|---|---|
|
AllocateCache() |
When in PreloadBytes mode, allocate if necessary the memory for the preloaded bytes. |
|
|
FArchive ... |
DetachLowerLevel() |
Return the LowerLevel FArchive if it has been allocated. |
|
FreeRetiredRequests() |
||
|
InitializeAsync ( |
Initialize the FPreloadableFile asynchronously, performing FileOpen operations on another thread. |
|
|
InitializeAsync ( |
Initialize the FPreloadableFile asynchronously, performing FileOpen operations on another thread. |
|
|
InitializeInternal ( |
Helper function for InitializeAsync, called from a TaskGraph thread. |
|
|
InitializeInternalAsync ( |
Helper function for InitializeAsync, sets up the asynchronous call to InitializeInternal |
|
|
IsCacheAllocated() |
Return whether the cache is currently allocated. |
|
|
IsInitialized() |
Return whether InitializeAsync has completed. |
|
|
IsPreloading() |
Return whether preloading is in progress. |
|
|
OnReadComplete ( |
||
|
PausePreload() |
||
|
ReleaseCache() |
Free all memory used by the cache or for preloading (calling StopPreload if necessary). |
|
|
ResumePreload() |
||
|
ResumePreloadNonRecursive() |
||
|
SerializeSynchronously |
||
|
SetPageSize ( |
Initialization. |
|
|
StartPreload() |
Preloading. |
|
|
StopPreload() |
Cancel any current asynchronous ReadRequests and wait for the asynchronous work to exit. |
|
|
WaitForInitialization() |
Wait for InitializeAsync to complete if it is running, otherwise return immediately. |
Name | Description | ||
---|---|---|---|
|
GetArchiveName() |
Returns the name of the Archive. |
|
|
Tell() |
Returns the current location within the backing data storage, which can possibly be passed to Seek later to restore a read/write location. |
|
|
TotalSize() |
Return the size of the file, or -1 if the file does not exist. |
Name |
Description |
|
---|---|---|
|
FSavedReadCompleteArguments |
Saved values from the inline OnReadComplete call |
Name |
Description |
|
---|---|---|
|
Flags |
Name |
Description |
---|---|
FCreateArchive |
|
FCreateAsyncArchive |
Name |
Description |
---|---|
DefaultPageSize |
|
DefaultPrimeSize |