Kanzi 3.9.10
ResourceManager.LoadTask Class Referenceabstract

Load task allows implementing custom asynchronous resource loading. More...

Inheritance diagram for ResourceManager.LoadTask:
[legend]

Public Member Functions

 LoadTask ()
 Construct a ResourceLoadTask of type LoadAndFinish.
 
 LoadTask (ResourceLoadTaskType type)
 Construct a ResourceLoadTask with the provided task type.
 
void close ()
 Closes the object, and releases the resources.
 
abstract void finishFunction ()
 The part of the loading that the main thread executes.
 
abstract ObjectRef<? extends ResourcegetResult ()
 Returns an owning reference to the created resource.
 
final ResourceLoadTaskType getType ()
 Get the type of a load task.
 
void loadFunction ()
 You can override this function to define the part of the resource loading task that a worker thread executes.
 

Protected Member Functions

final void enqueueDependencies (String[] urls)
 Add resource dependencies for the load task.
 
final ResourceManager getResourceManager ()
 Get the resource manager of a load task.
 

Detailed Description

Load task allows implementing custom asynchronous resource loading.

A load task is split into an optional com.rightware.kanzi.LoadTask#loadFunction and mandatory com.rightware.kanzi.LoadTask#finishFunction. Kanzi can execute the com.rightware.kanzi.LoadTask#loadFunction in a background worker thread, instead of the main thread. For this reason, perform here only thread-independent work. Kanzi calls the com.rightware.kanzi.LoadTask#loadFunction in the main thread. The load task execution happens in this order:

Constructor & Destructor Documentation

◆ LoadTask()

Construct a ResourceLoadTask with the provided task type.

Parameters
typeThe task type that configures which task functions are called.

Member Function Documentation

◆ enqueueDependencies()

final void enqueueDependencies ( String[] urls)
protected

Add resource dependencies for the load task.

Can be called any number of times inside a com.rightware.kanzi.LoadTask#loadFunction implementation. Informs the main thread of the dependencies, which can then trigger their async loading.

Parameters
urlsArray of dependency urls.

◆ finishFunction()

abstract void finishFunction ( )
abstract

The part of the loading that the main thread executes.

The function creates and stores a new resource that com.rightware.kanzi.LoadTask#getResult() returns.

◆ getResourceManager()

final ResourceManager getResourceManager ( )
protected

Get the resource manager of a load task.

Returns
The resource manager.

◆ getResult()

abstract ObjectRef<? extends Resource > getResult ( )
abstract

Returns an owning reference to the created resource.

Returns
The created resource.

◆ getType()

Get the type of a load task.

Returns
The type of the load task.

◆ loadFunction()

void 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.