41 #ifndef _asynchronousfileloadingworkunit_cpp
42 #define _asynchronousfileloadingworkunit_cpp
61 }
catch (std::exception&){
65 for(std::vector<String>::iterator CurrentFileName = Unit.
Filenames.begin(); CurrentFileName!=Unit.
Filenames.end(); CurrentFileName++)
67 std::ifstream File(CurrentFileName->c_str(), std::ios::binary | std::ios::ate);
70 MaxInt FileLength = File.tellg();
71 File.seekg(0,std::ios::beg);
75 Loading =
new RawFile(FileLength);
76 }
catch (std::exception&){
81 File.read((
char*)Loading->
Data, FileLength);
131 for(std::vector<String>::const_iterator CurrentFileName =
Filenames.begin();
133 CurrentFileName++, Index++)
135 if(*CurrentFileName==FileName)
152 for(RawFileContainer::iterator Iter=
FilesRaw.begin(); Iter!=
FilesRaw.end(); ++Iter)
UInt8 * Data
A pointer to a block of memory as it was loaded raw from the file.
void ThreadLoading(void *WU)
An Internal helper function for the AsynchronousFileLoadWorkUnit. This is the function that Asynchron...
RunningState
Used to track whether a thread has started, completed, etc...
AsynchronousFileLoadWorkUnit()
Default constructor.
RawFileContainer FilesRaw
The contents of the files once they have been loaded. No partial files will exists here...
The declaration of the AsynchronousFileLoadWorkUnit a workunit that loads a listing of files asynchro...
virtual void DoWork(DefaultThreadSpecificStorage::Type &)
This checks if Asynchronous loading thread has completed and if so it cleans up that threads' resourc...
Indicates an abnormal termination of a Workunit or other failure, Likely the whole application will n...
Int32 Status
This stores the current RunningState.
Only used when a thread successfully attempts to gain ownership of a task, or some other tasks succes...
A thread specific collection of double-buffered and algorithm specific resources. ...
A small wrapper around the system thread.
A simple in memory representation of a file.
Int32 AtomicCompareAndSwap32(Int32 *VariableToChange, const Int32 &OldValue, const Int32 &NewValue)
Atomically Compares And Swaps a 32 bit value.
Task is running when the value was check, it could become Complete or Failed with no notice...
std::vector< String > Filenames
The names of the files this batch of loading will retrieve.
RawFile * GetFile(const String &FileName) const
Get a loaded RawFile in linear time.
virtual ~AsynchronousFileLoadWorkUnit()
Destructor, deletes all loaded files.
This is intended to load files asynchronously and continue doing so whether or not other the FrameSch...
void DeleteLoadedFiles()
This deletes all the loaded files from the last call of BeginLoading .
virtual RunningState IsWorkDone()
Get the RunningState of the file loading.
RunningState BeginLoading(const std::vector< String > &Filenames_)
Begin loading a list of files based on their names.
Task is not yet started this frame, this can change without notice.
Simple thread safe ways to check and change a specified variable atomically.
long long MaxInt
A large integer type suitable for compile time math and long term microsecond time keeping...
Thread has completed all work this from frame, will not change until this frame ends.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Thread * LoadingThread
This is either 0 or the other thread that is loading.
std::string String
A datatype used to a series of characters.
void join()
Wait for the thread to finish (join execution flows).