◆ fiftyoneDegreesResourceHandleDecUse()
void fiftyoneDegreesResourceHandleDecUse | ( | fiftyoneDegreesResourceHandle * | handle | ) |
Decrements the usage counter.
If the count reaches zero then resource will become eligible to be freed either when the manager replaces it or when the manager is freed.
- Parameters
-
- handle - to the resource which should be released by the manager
◆ fiftyoneDegreesResourceHandleIncUse()
fiftyoneDegreesResourceHandle* fiftyoneDegreesResourceHandleIncUse ( fiftyoneDegreesResourceManager * manager ) Increments the usage counter for the resource and returns a handle that can be used to reference it.
The handle MUST be used to decrement the use count using the fiftyoneDegreesResourceHandleDecUse method when the resource is finished with. The resource can be guaranteed not to be freed until after the decrement method has been called.
- Parameters
-
- manager - the resource manager to initialise with the resource
◆ fiftyoneDegreesResourceManagerFree()
void fiftyoneDegreesResourceManagerFree ( fiftyoneDegreesResourceManager * manager ) Frees any data associated with the manager and releases the resource making it eligible for freeing.
IMPORTANT : The resource itself is not necessarily freed after this operation i.e. if there are still handles pointing to this resource, then the freeing will be left until the last handle is released. For this reason, the manager pointer MUST remain valid until the last handle has been released.
- Parameters
-
- manager - the resource manager to initialise with the resource
- Examples
- Hash/GettingStarted.c, Hash/MatchMetrics.c, Hash/OfflineProcessing.c, and Hash/StronglyTyped.c.
◆ fiftyoneDegreesResourceManagerInit()
void fiftyoneDegreesResourceManagerInit ( fiftyoneDegreesResourceManager * manager, void * resource, fiftyoneDegreesResourceHandle ** resourceHandle, void(*)(void *) freeResource ) Initialise a preallocated resource manager structure with a resource for it to manage access to.
The resourceHandle parameter must point to the handle within the resource under management so that the handle can be assigned to the resource before the resource is placed under management.
IMPORTANT : The pointer to the manager MUST remain valid for the duration of any resource's existence i.e. until the last handle has been released and the resource freed.
- Parameters
-
- manager - the resource manager to initialise with the resource
- resource - pointer to the resource which the manager should manage access to
- resourceHandle - points to the location the new handle should be stored
- freeResource - method to use when freeing the resource
◆ fiftyoneDegreesResourceReplace()
void fiftyoneDegreesResourceReplace ( fiftyoneDegreesResourceManager * manager, void * newResource, fiftyoneDegreesResourceHandle ** newResourceHandle ) Replaces the resource with the new resource.
If the existing resource is not being used it will be freed. Otherwise it is left to the decrement function to free the resource when the usage count is zero.
- Parameters
-
- manager - the resource manager to initialise with the resource
- newResource - pointer to the resource which the manager should manage access to
- newResourceHandle - points to the location the new handle should be stored