This is intended to load files asynchronously and continue doing so whether or not other the FrameScheduler is running or paused. More...
#include <asynchronousfileloadingworkunit.h>
Public Member Functions | |
AsynchronousFileLoadWorkUnit () | |
Default constructor. | |
virtual | ~AsynchronousFileLoadWorkUnit () |
Destructor, deletes all loaded files. | |
RunningState | BeginLoading (const std::vector< String > &Filenames_) |
Begin loading a list of files based on their names. More... | |
void | DeleteLoadedFiles () |
This deletes all the loaded files from the last call of BeginLoading . | |
virtual void | DoWork (DefaultThreadSpecificStorage::Type &) |
This checks if Asynchronous loading thread has completed and if so it cleans up that threads' resources. | |
RawFile * | GetFile (const String &FileName) const |
Get a loaded RawFile in linear time. More... | |
RawFile * | GetFile (const Whole &Index) const |
Retrieve a pointer to file contents in constant time. More... | |
virtual RunningState | IsWorkDone () |
Get the RunningState of the file loading. More... | |
Protected Types | |
typedef std::vector< RawFile * > | RawFileContainer |
Used to make referencing the the type of FilesRaw easier. | |
Protected Attributes | |
std::vector< String > | Filenames |
The names of the files this batch of loading will retrieve. | |
RawFileContainer | FilesRaw |
The contents of the files once they have been loaded. No partial files will exists here, either the whole file is added or nothing is added. | |
Thread * | LoadingThread |
This is either 0 or the other thread that is loading. | |
Int32 | Status |
This stores the current RunningState. | |
This is intended to load files asynchronously and continue doing so whether or not other the FrameScheduler is running or paused.
The goal is to trigger lower level mechanisms to use DMA to load directly without CPU intervention. In some operating systems this is handled in the standard library, and in others special mechanisms must be used to make this happen. The current state of this allows testing to determine how good automatic mechanisms work.
Definition at line 100 of file asynchronousfileloadingworkunit.h.
RunningState Mezzanine::Threading::AsynchronousFileLoadWorkUnit::BeginLoading | ( | const std::vector< String > & | Filenames_) |
Begin loading a list of files based on their names.
Filenames_ | A vector of Strings that correspond to either relative or absolute filenames that will be loaded. |
When the file is loaded its contents are placed in a RawFile and can be retrieved with GetFile or GetFile member functions.
This starts by clearing the previous list of loaded files. If that list has not been deleted then this will cause a memory leak. Use DeleteLoadedFiles to clear this list or copy all the pointers elsewhere before calling this and delete them manually at your convience. When this work unit is destroyed it deletes any loaded files from the last call of this method.
If this is called while it is loading files the behavior is undefined, most likely it will crash or fail silently, either way no good can come from it. Use IsWorkDone to see if the work is Complete. If the work is complete then this can be called after any call to this class's DoWork member function.
Definition at line 100 of file asynchronousfileloadingworkunit.cpp.
RawFile * Mezzanine::Threading::AsynchronousFileLoadWorkUnit::GetFile | ( | const String & | FileName) | const |
Get a loaded RawFile in linear time.
This searches the list of files names to determine the index of the filename then calls GetFile.
FileName | The file to retrieve. |
Definition at line 128 of file asynchronousfileloadingworkunit.cpp.
Retrieve a pointer to file contents in constant time.
Index | The index of the File Name when it was passed into BeginLoading. |
Definition at line 141 of file asynchronousfileloadingworkunit.cpp.
|
virtual |
Get the RunningState of the file loading.
This can return any RunningState and the meaning applies to the current state of the files being loaded.
Implements Mezzanine::Threading::iAsynchronousWorkUnit.
Definition at line 125 of file asynchronousfileloadingworkunit.cpp.