Use this base class to implement the load tasks that load new resources.
More...
#include <kanzi/core.ui/resource/resource_manager.hpp>
Use this base class to implement the load tasks that load new resources.
A load task is split into an optional loadFunction and mandatory finishFunction. The loadFunction may be called in a background worker thread, instead of the main thread. And so only thread independent work should be done here. While the finishFunction is guaranteed to be called in the main thread. The load task execution happens in this order:
- The loading thread or main thread execute the loadFunction.
- The main thread executes the finishFunction.
- The load task returns the created resource with getResult. Inside the loadFunction, a call to enqueueDependencies can be made to trigger background loading of dependencies.
◆ Type
The type of the load task.
◆ LoadTask() [1/2]
kanzi::ResourceManager::LoadTask::LoadTask |
( |
| ) |
|
|
explicit |
Constructor.
Type is set to LoadAndFinish.
◆ LoadTask() [2/2]
kanzi::ResourceManager::LoadTask::LoadTask |
( |
const Type |
type | ) |
|
|
explicit |
◆ ~LoadTask()
virtual kanzi::ResourceManager::LoadTask::~LoadTask |
( |
| ) |
|
|
virtual |
◆ loadFunction()
You can override this function to define the part of the resource loading task that a worker thread executes.
You cannot access any shared data inside the function.
- Parameters
-
resourceLoaderThreadContext | The context of the loader thread. |
Implemented in kanzi::ResourceProfilingLoadTask.
◆ finishFunction()
The part of the loading that the main thread executes.
The function creates and stores a new resource that getResult returns.
- Parameters
-
resourceLoaderThreadContext | The context of the loader thread that was used to call loadFunction. |
Implemented in kanzi::ResourceProfilingLoadTask.
◆ getResult()
◆ getType()
Type kanzi::ResourceManager::LoadTask::getType |
( |
| ) |
const |
Get the type of a load task.
- Returns
- The type of the load task.
◆ getResourceManager()
ResourceManager* kanzi::ResourceManager::LoadTask::getResourceManager |
( |
| ) |
const |
Get the resource manager of a load task.
- Returns
- Pointer to resource manager.
◆ enqueueDependencies()
void kanzi::ResourceManager::LoadTask::enqueueDependencies |
( |
UrlContainer |
urls | ) |
|
|
protected |
Add resource dependencies for the load task.
Can be called any number of times inside a loadFunction implementation. Informs the main thread of the dependencies, which can then trigger their async loading.
- Parameters
-
urls | Container of dependency urls. |
◆ ResourceManager
◆ FinishingQueue
The documentation for this struct was generated from the following file: