Tramway SDK
Classes | Functions
tram::Async Namespace Reference

Classes

struct  ResourceRequest
 

Functions

void RequestResource (EntityComponent *requester, Resource *resource)
 Adds a resource to the loading queue. More...
 
void CancelRequest (EntityComponent *requester, Resource *resource)
 Cancels a resource load request. More...
 
void LoadDependency (Resource *res)
 Loads a resource from disk, skipping the queue. More...
 
void LoadResourcesFromDisk ()
 Processes the first resource queue. More...
 
void LoadResourcesFromMemory ()
 Processes the second resource queue. More...
 
void FinishResources ()
 Notifies EntityComponents about finished resources. More...
 
void Init (size_t threads)
 Starts the async resource loader thread. More...
 
void Yeet ()
 Stops the async resource loader thread. More...
 
size_t GetWaitingResources ()
 Returns number of resources in queues. More...
 

Function Documentation

◆ CancelRequest()

void tram::Async::CancelRequest ( EntityComponent requester,
Resource resource 
)

Cancels a resource load request.

Should be called if the EntityComponent that requested a Resource to be loaded will be destructed before the Resource has finished loading.

Note
The resource will be fully loaded anyway, but the requester will not be notified.

◆ FinishResources()

void tram::Async::FinishResources ( )

Notifies EntityComponents about finished resources.

◆ GetWaitingResources()

size_t tram::Async::GetWaitingResources ( )

Returns number of resources in queues.

◆ Init()

void tram::Async::Init ( size_t  threads)

Starts the async resource loader thread.

Parameters
Numberof threads for async loading.

◆ LoadDependency()

void tram::Async::LoadDependency ( Resource res)

Loads a resource from disk, skipping the queue.

Shouldn't be used outside of resource LoadFromDisk() methods.

◆ LoadResourcesFromDisk()

void tram::Async::LoadResourcesFromDisk ( )

Processes the first resource queue.

If you started the Async system with at least one thread, you don't need to call this function.

◆ LoadResourcesFromMemory()

void tram::Async::LoadResourcesFromMemory ( )

Processes the second resource queue.

Warning
This function should only be called from the rendering thread.

◆ RequestResource()

void tram::Async::RequestResource ( EntityComponent requester,
Resource resource 
)

Adds a resource to the loading queue.

Parameters
requesterEntityComponent that will be notified when the resource is loaded. Can be set to nullptr, in which case nothing will be notified.
requested_resourceThe resource that will be loaded.

◆ Yeet()

void tram::Async::Yeet ( )

Stops the async resource loader thread.