◆ 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
◆ fiftyoneDegreesResourceHandleGetUse()
int32_t fiftyoneDegreesResourceHandleGetUse ( fiftyoneDegreesResourceHandle * handle ) Return the current usage counter.
WARNING: This call is not thread-safe and is suitable for using in testing only.
- Parameters
-
- handle - to the resource which should be released by the manager
- Returns
- the current usage counter
◆ 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 manager.
All memory is released after this operation.
- Parameters
-
- manager - the resource manager to be freed
- Examples
- Hash/MatchMetrics.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.
- 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