Drag[en]gine Game Engine  1.0
deResourceLoader Class Reference

Resource Loader. Loads resources asynchronously. To load a resource a scripting module places a load request. Requests are processed using a pool of worker threads and once finished are promoted to the retrieval queue. The scripting module has to query the resource loader during each frame update for new entries in the retrieval queue. Once there are no more entries in the queue the scripting module can carry on with the fram update. Requests for the same resource are grouped together and placed in the retrieval queue only once. The scripting module is responsible to track multiple requests for the same resource. A resource is uniquely identified by the path and resource type. This informations are also returned in retrieval queries and can be used to match up with one or more requests made by the game scripts. The pause loading flag indicates if loading of new resources is put at hold. This is used during crash recovery breaks to avoid threads loading resources in the background causing havok. Changing the flag to false blocks until all threads still loading a resource have finished. More...

#include <deResourceLoader.h>

Public Types

enum  eResourceTypes {
  ertAnimation, ertFont, ertImage, ertModel,
  ertRig, ertSkin, ertSound, ertOcclusionMesh
}
 

Public Member Functions

Constructors and Destructors
 deResourceLoader (deEngine *engine)
 
 ~deResourceLoader ()
 
Management
bool GetOutputDebugMessages () const
 
void Update ()
 
void AddLoadRequest (const char *path, eResourceTypes resourceType)
 
void AddLoadRequest (deVirtualFileSystem *vfs, const char *path, eResourceTypes resourceType)
 
bool NextFinishedRequest (deResourceLoaderInfo &info)
 
bool GetPauseLoading () const
 
void PauseLoading ()
 
void ResumeLoading ()
 
void RemoveAllTasks ()
 Stop loading and remove all tasks. More...
 
deResourceLoaderTaskGetNextPendingTask ()
 
void WaitOnNewTasksSemaphore ()
 
void AddFinishedTask (deResourceLoaderTask *task)
 
void AddDebugMessage (const char *message)
 
void LogDebugMessages ()
 

Friends

class deRLInternalSkinProperty
 
class deRLInternalSkinPropertyNode
 

Detailed Description

Resource Loader. Loads resources asynchronously. To load a resource a scripting module places a load request. Requests are processed using a pool of worker threads and once finished are promoted to the retrieval queue. The scripting module has to query the resource loader during each frame update for new entries in the retrieval queue. Once there are no more entries in the queue the scripting module can carry on with the fram update. Requests for the same resource are grouped together and placed in the retrieval queue only once. The scripting module is responsible to track multiple requests for the same resource. A resource is uniquely identified by the path and resource type. This informations are also returned in retrieval queries and can be used to match up with one or more requests made by the game scripts. The pause loading flag indicates if loading of new resources is put at hold. This is used during crash recovery breaks to avoid threads loading resources in the background causing havok. Changing the flag to false blocks until all threads still loading a resource have finished.

Author
Pl├╝ss Roland
Version
1.0
Date
2012

Member Enumeration Documentation

◆ eResourceTypes

Resource types.

Enumerator
ertAnimation 
ertFont 
ertImage 
ertModel 
ertRig 
ertSkin 
ertSound 
ertOcclusionMesh 

Constructor & Destructor Documentation

◆ deResourceLoader()

deResourceLoader::deResourceLoader ( deEngine engine)

Creates a new resource loader.

◆ ~deResourceLoader()

deResourceLoader::~deResourceLoader ( )

Cleans up the resource loader.

Member Function Documentation

◆ AddDebugMessage()

void deResourceLoader::AddDebugMessage ( const char *  message)

Adds a debug message (thread-safe).

Referenced by GetPauseLoading().

◆ AddFinishedTask()

void deResourceLoader::AddFinishedTask ( deResourceLoaderTask task)

Adds a task to the list of finished tasks. Called by worker threads only (thread-safe).

Referenced by GetPauseLoading().

◆ AddLoadRequest() [1/2]

void deResourceLoader::AddLoadRequest ( const char *  path,
eResourceTypes  resourceType 
)

Add request for loading a resource.

Referenced by GetOutputDebugMessages().

◆ AddLoadRequest() [2/2]

void deResourceLoader::AddLoadRequest ( deVirtualFileSystem vfs,
const char *  path,
eResourceTypes  resourceType 
)

Add request for loading a resource.

◆ GetNextPendingTask()

deResourceLoaderTask* deResourceLoader::GetNextPendingTask ( )

Retrieves the next pending task or NULL if there is none. Called by worker threads only (thread-safe).

Referenced by GetPauseLoading().

◆ GetOutputDebugMessages()

bool deResourceLoader::GetOutputDebugMessages ( ) const
inline

Determines if debug messages are output to the engine logger.

References AddLoadRequest(), NextFinishedRequest(), and Update().

◆ GetPauseLoading()

bool deResourceLoader::GetPauseLoading ( ) const
inline

◆ LogDebugMessages()

void deResourceLoader::LogDebugMessages ( )

Output debug messages to the logger. Thread safe call.

Referenced by GetPauseLoading().

◆ NextFinishedRequest()

bool deResourceLoader::NextFinishedRequest ( deResourceLoaderInfo info)

Retrieves informations about the next finished request. Returns true if a finished request has been retrieved or false if there are no more finished requests. After returing true the requests has been removed.

Referenced by GetOutputDebugMessages().

◆ PauseLoading()

void deResourceLoader::PauseLoading ( )

Pause loading. This call blocks until all threads with loading in progress have finished.

Referenced by GetPauseLoading().

◆ RemoveAllTasks()

void deResourceLoader::RemoveAllTasks ( )

Stop loading and remove all tasks.

Used by the game engine to clear pending tasks upon cleanup avoiding problems.

Referenced by GetPauseLoading().

◆ ResumeLoading()

void deResourceLoader::ResumeLoading ( )

Resumes loading.

Referenced by GetPauseLoading().

◆ Update()

void deResourceLoader::Update ( )

Called once a frame to update tasks. Assigns tasks to waiting threads and promotes finished tasks to the retrieval queue. Called by the game engine before the scripting module does frame updates.

Referenced by GetOutputDebugMessages().

◆ WaitOnNewTasksSemaphore()

void deResourceLoader::WaitOnNewTasksSemaphore ( )

Waits on the new tasks semaphore. Called by worker threads only.

Referenced by GetPauseLoading().

Friends And Related Function Documentation

◆ deRLInternalSkinProperty

friend class deRLInternalSkinProperty
friend

◆ deRLInternalSkinPropertyNode

friend class deRLInternalSkinPropertyNode
friend

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