EtcPal
0.4.1
ETC Platform Abstraction Layer (EtcPal)
|
View other versions:
|
A utility to manage handing out integer handles to resources.
This struct and the accompanying functions are a utility to manage handing out integer handles to resources. It first assigns monotonically-increasing positive values starting at 0 to handles; after wraparound, it uses the value_in_use function to find holes where new handle values can be assigned.
Data Structures | |
struct | IntHandleManager |
State for managing generic integer handle values. More... | |
Typedefs | |
typedef bool(* | HandleValueInUseFunction) (int handle_val, void *context) |
A pointer to a function that tests if a given handle value is currently assigned to a resource. | |
typedef struct IntHandleManager | IntHandleManager |
State for managing generic integer handle values. | |
Functions | |
void | init_int_handle_manager (IntHandleManager *manager, int max_value, HandleValueInUseFunction value_in_use_func, void *context) |
Initialize an IntHandleManager instance. More... | |
int | get_next_int_handle (IntHandleManager *manager) |
Once the int handle manager is initialized, this is used to get the next handle value. More... | |
int get_next_int_handle | ( | IntHandleManager * | manager | ) |
Once the int handle manager is initialized, this is used to get the next handle value.
This function provides the next handle value that is not currently assigned to a resource.
[in,out] | manager | The handle manager to get the new handle from. |
void init_int_handle_manager | ( | IntHandleManager * | manager, |
int | max_value, | ||
HandleValueInUseFunction | value_in_use_func, | ||
void * | context | ||
) |
Initialize an IntHandleManager instance.
Once an IntHandleManager has been instantiated, it should be passed to this function to initialize its state.
[in,out] | manager | The handle manager instance to initialize. |
[in] | max_value | Determines a custom wrap-around point. It will be ignored if it's negative. Otherwise it represents the highest allowed handle value. |
[in] | value_in_use_func | The function that tests if a given handle value is currently assigned to a resource. |
[in,out] | context | An optional pointer that will be passed to the value-in-use function. This can be NULL. |