kanzi::ResourceManager::LoadTask Struct Referenceabstract

Use this base class to implement the load tasks that load new resources. More...

#include <kanzi/core.ui/resource/resource_manager.hpp>

Inheritance diagram for kanzi::ResourceManager::LoadTask:
kanzi::ResourceProfilingLoadTask

Public Types

enum  State { NotStarted, InProgress, Completed }
 The state of the load task. More...
 

Public Member Functions

 LoadTask ()
 Constructor. More...
 
virtual ~LoadTask ()
 Destructor. More...
 
virtual void loadFunction (const ResourceLoaderThreadContext *resourceLoaderThreadContext)=0
 You can override this function to define the part of the resource loading task that a worker thread executes. More...
 
virtual void finishFunction (const ResourceLoaderThreadContext *resourceLoaderThreadContext)=0
 The part of the loading that the main thread executes. More...
 
virtual ResourceSharedPtr getResult ()=0
 Returns the created resource. More...
 

Friends

class ResourceManager
 
class FinishingQueue
 

Detailed Description

Use this base class to implement the load tasks that load new resources.

A load task consist of:

  • Loading part. Implement the loading part by overriding the loadFunction.
  • Finishing part. Implement the finishing part by overriding the finishFunction.

The load task execution happens in this order:

  1. The loading thread executes the loadFunction.
  2. The main thread executes the finishFunction.
  3. The load task returns the created resource with getResult.

Member Enumeration Documentation

The state of the load task.

Enumerator
NotStarted 

The loading has not started.

InProgress 

The load task is in the loading queue.

Completed 

The loadFunction and finishFunction are executed.

Constructor & Destructor Documentation

kanzi::ResourceManager::LoadTask::LoadTask ( )
inlineexplicit

Constructor.

virtual kanzi::ResourceManager::LoadTask::~LoadTask ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual void kanzi::ResourceManager::LoadTask::loadFunction ( const ResourceLoaderThreadContext resourceLoaderThreadContext)
pure virtual

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
resourceLoaderThreadContextThe context of the loader thread.

Implemented in kanzi::ResourceProfilingLoadTask.

virtual void kanzi::ResourceManager::LoadTask::finishFunction ( const ResourceLoaderThreadContext resourceLoaderThreadContext)
pure virtual

The part of the loading that the main thread executes.

The function creates and stores a new resource that getResult returns.

Parameters
resourceLoaderThreadContextThe context of the loader thread that was used to call loadFunction.

Implemented in kanzi::ResourceProfilingLoadTask.

virtual ResourceSharedPtr kanzi::ResourceManager::LoadTask::getResult ( )
pure virtual

Returns the created resource.

Returns
The created resource.

Implemented in kanzi::ResourceProfilingLoadTask.

Friends And Related Function Documentation

friend class ResourceManager
friend
friend class FinishingQueue
friend

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