class
ResourceHandle
Represents a handle to a resource.
Handles are similar to a smart pointers, but they have two advantages:
- When loading a resource asynchronously you can be immediately returned the handle that you may use throughout the engine. The handle will be made valid as soon as the resource is loaded.
- Handles can be serialized and deserialized, therefore saving/restoring references to their original resource.
Public
Methods
IsLoaded
Checks if the resource is loaded.
Until resource is loaded this handle is invalid and you may not get the internal resource from it.
- checkDependencies
- If true, and if resource has any dependencies, this method will also check if they are loaded.
IsValid
Checks if the resource handle is not null and resource is loaded.
BlockUntilLoaded
Blocks the current thread until the resource is fully loaded.
Destroy
Forces the resource to be unloaded and destroyed, regardless of reference count.
ReleaseInternalReference
Releases an internal reference to this resource held by the resources system, if there is one.
GetReferenceCount
Returns the number of strong references on the resource pointed by the handle.
Internal
Methods
GetHandleData
Gets the handle data.
For internal use only.
Protected
Methods
AssociateResourceWithHandle
Sets the created flag to true and assigns the resource pointer.
Called by the constructors, or if you constructed just using a UUID, then you need to call this manually before you can access the resource from this handle.
IncrementStrongReferenceCount
Increments the strong reference count.
As long as strong reference count is non-zero the handle will keep the managed resource alive.
DecrementStrongReferenceCount
Decrements the strong reference count.
If the strong reference count reaches zero the managed resource will be destroyed. Additionally if there are no weak resource handles alive either, resource handle data will also be destroyed.
IncrementWeakReferenceCount
Increments the weak reference count.
This keeps the resource handle data alive, but not the managed resource itself.
DecrementWeakReferenceCount
Decrements the weak reference count.
If this was the last weak reference and there are no strong references either, handle data will be destroyed.
NotifyLoadComplete
Notification sent by the resource system when the resource is done with the loading process.
This will trigger even if the load fails.