|
Tramway SDK v0.1.1
|
Multi-threading and Resource streaming. More...
Classes | |
| struct | ResourceRequest |
Enumerations | |
| enum | RequestNotification { NONE , COMPONENT , CALLBACK } |
Functions | |
| void | RequestResource (EntityComponent *requester, Resource *resource) |
| Adds a resource to the loading queue. More... | |
| void | RequestResource (void(*callback)(void *data), void *data, 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 *resource) |
| 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... | |
Multi-threading and Resource streaming.
Currently Async only does Resource streaming, but we could do other kinds of Async processing in the future too.
| 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.
| void tram::Async::FinishResources | ( | ) |
Notifies EntityComponents about finished resources.
| size_t tram::Async::GetWaitingResources | ( | ) |
Returns number of resources in queues.
| void tram::Async::Init | ( | size_t | threads | ) |
Starts the async resource loader thread.
| Number | of threads for async loading. |
| void tram::Async::LoadDependency | ( | Resource * | resource | ) |
Loads a resource from disk, skipping the queue.
Shouldn't be used outside of resource LoadFromDisk() methods.
| void tram::Async::LoadResourcesFromDisk | ( | ) |
Processes the first resource queue.
If there are any resource loader threads active, this function will not do anything, instead allowing the loader threads to load the resources.
| void tram::Async::LoadResourcesFromMemory | ( | ) |
Processes the second resource queue.
| void tram::Async::RequestResource | ( | EntityComponent * | requester, |
| Resource * | resource | ||
| ) |
Adds a resource to the loading queue.
| requester | EntityComponent that will be notified when the resource is loaded. Can be set to nullptr, in which case nothing will be notified. |
| requested_resource | The resource that will be loaded. |
| void tram::Async::RequestResource | ( | void(*)(void *data) | callback, |
| void * | data, | ||
| Resource * | resource | ||
| ) |
Adds a resource to the loading queue.
| callback | Callback function which will be called when the resource has been loaded and is ready for use. |
| data | Data pointer, which will be passed to as a parameter to the callback function. |
| requested_resource | The resource that will be loaded. |
| void tram::Async::Yeet | ( | ) |
Stops the async resource loader thread.