Skip to content

Std resource resource

std:std.resource.Resource

Class Resource#

The Resource class.

The resource class helps with managing finite OS resources in a garbage collected environment.

To implement a resource object, you should extend the Resource class and override the OnDiscard and/or OnFinalize methods.

Code to actually discard the resource should be placed in OnDiscard. Discarding a resource might involve closing a file, deleting a texture handle or other similar actions. 'Last chance' cleanup code should be placed in OnFinalize.

IMPORTANT! There are a number of restrictions on code that may be placed in OnFinalize, please refer to the documentation for OnFinalize for more information.

Methods
Discard Discards the resource.
Protected methods
OnDiscard The OnDiscard method.
OnFinalize The OnFinalize method.