|
resonance 1.0.1
|
Request to load one renderer file in the background. More...
#include <asyncloader.h>
Public Member Functions | |
| RndAsyncLoader () | |
| Prepare an empty request with no directory or file. | |
| RndAsyncLoader (const HxStr &directory, const HxStr &file, int nZone) | |
| Prepare a load request. | |
| ~RndAsyncLoader () | |
| Release the request and any partially loaded data. | |
| void | Enqueue () |
| Add this request to the load queue. | |
| void | Cancel () |
| Abandon this request. | |
| void | Restart (const HxStr &directory, const HxStr &file) |
| Abandon this request and point it at another file. | |
| void | Unload () |
| Abandon this request and release everything it has loaded, leaving it ready to start again. | |
| int | Poll (float *pfProgress) |
| Test whether this request has finished and report how far it has advanced. | |
Static Public Member Functions | |
| static void * | operator new (size_t nSize) |
| Allocate a request under the tag RndAsyncLoader. | |
| static void | operator delete (void *pBlock) |
| Release a request under the tag RndAsyncLoader. | |
| static void | PollAsyncLoads () |
| Advance every queued load request. | |
Public Attributes | |
| std::list< Rnd::Object * > | mObjects |
| The objects the request has produced so far. | |
| std::list< Rnd::Drawable * > | mDrawables |
| Drawables the container load produced. | |
| int | mPending |
| Starts set and reports no progress while it stays set. | |
Request to load one renderer file in the background.
The class is not polymorphic and has no RTTI, so its title is inferred. A request is constructed with the directory and file to load, then enqueued. Callers advance the queue with PollAsyncLoads() and test the individual request with Poll() until it reports completion.
The object is 0x2c bytes. The constructor builds three std::list members at +0x00, +0x04, and +0x08, each of which takes a 0x10-byte sentinel; that bounds their element at 8 bytes or less, so all three are lists of pointers rather than of records. The list at +0x00 stores the objects the request has produced so far, which is what Poll() counts and what RndAsyncLoader::HarvestLoadedObjects() fills. Everything from +0x0c on is declared below. The three flag titles are inferred from their initial values and from the order Poll() tests them in.
| RndAsyncLoader::RndAsyncLoader | ( | ) |
Prepare an empty request with no directory or file.
The request starts pending, with its file not read and its textures not finished, and with no zone. The image lists no caller for the out-of-line body.
Prepare a load request.
| directory | The directory to load from. |
| file | The file to load. |
| nZone | The zone PollAsyncLoads() selects while it reads the objects, or kNoZone. |
| RndAsyncLoader::~RndAsyncLoader | ( | ) |
Release the request and any partially loaded data.
| void RndAsyncLoader::Enqueue | ( | ) |
Add this request to the load queue.
A request already in either queue logs an internal error with its directory and file and is not added again. The first request resolves g_nRndLoaderZone from the zone "rndfile". The request is then marked not pending, not read, and not finished, and appended to gPendingRndFiles.
| void RndAsyncLoader::Cancel | ( | ) |
Abandon this request.
A request whose file has been read is not affected. Otherwise its read is cancelled and its entry removed from gInProgressRndFiles, and it is removed from gPendingRndFiles.
Abandon this request and point it at another file.
Runs Cancel(), replaces the directory and the file, and marks the request pending, not read, and not finished. Unlike Unload() it releases nothing that was already loaded. The image lists no caller, and the title is inferred.
| directory | The directory to load from. |
| file | The file to load. |
| void RndAsyncLoader::Unload | ( | ) |
Abandon this request and release everything it has loaded, leaving it ready to start again.
Runs Cancel(), then, unless the request is still pending, deletes every object in mLoadedObjects through its destructor, clears the three lists, and marks the request pending, not read, and not finished. The destructor runs it first, and Renderer::UnloadCommon() runs it before each delete as well. The title is inferred.
|
inlinestatic |
Allocate a request under the tag RndAsyncLoader.
Every new-expression open-codes the call.
| nSize | The object size the compiler supplies. |
|
inlinestatic |
Release a request under the tag RndAsyncLoader.
The deleting branch of the destructor open-codes the call.
| pBlock | The block. |
| int RndAsyncLoader::Poll | ( | float * | pfProgress | ) |
Test whether this request has finished and report how far it has advanced.
The fraction is the proportion of the textures in mObjects whose mip levels have all arrived, each polled once through Rnd::Tex::PollAsyncMips(). A request still pending, or one whose file has not been read, reports 0. A request already marked finished reports 1, and one whose textures are all loaded is marked finished.
| pfProgress | Receives a fraction between 0 and 1. |
|
static |
Advance every queued load request.
Runs with g_nRndLoaderZone selected and restores the previous zone on return. The zone is reset when requests are waiting and no read is in flight. Each waiting request then has gen/<file>.gz under its directory read into a block of that zone and moves to gInProgressRndFiles, until a file does not fit. A file of length 0 raises "RndAsyncLoader::Poll(): couldn't find: %s".
The reads are then collected in issue order. The first one still in flight stops the collection. A failed read logs "ERROR reading RND file async: %s:%s!!" and is dropped. A finished read selects the request's zone, loads the objects through Rnd::TheManager, marks the file read, and ends the collection. Only one file is loaded per call.
| std::list<Rnd::Object *> RndAsyncLoader::mObjects |
The objects the request has produced so far.
+0x00
Poll() counts it and RndAsyncLoader::HarvestLoadedObjects() fills it. Public because MetFreqMakerAssetManager::GetLoadedObjects() and MetFreqMakerAssetManager::PollLoad() copy it directly, and the image has no accessor.
| std::list<Rnd::Drawable *> RndAsyncLoader::mDrawables |
Drawables the container load produced.
MetScreen::SetShowing() copies the list and shows or hides every entry, which is what fixes the element as a drawable rather than a bare object. Public because that read comes from outside the hierarchy and the image has no accessor to route it through. A friend declaration fits the image equally well. The member is declared between mObjects and the private list after it so that the recovered order, and therefore the recovered layout, is preserved. +0x04
| int RndAsyncLoader::mPending |
Starts set and reports no progress while it stays set.
+0x1c
Public because MetRenderer's loader routines at 0x00371270 and 0x00371438 read it directly before Enqueue(), and the image has no accessor for it.