Skip to content

ID Allocator (id_space)

include/structures/id_space.h View source View on GitHub
struct id_range (4 fields) source
§ struct rbt_node node
§ uint64_t start
§ uint64_t length
§ struct id_range *next
struct id_space (4 fields) source
§ struct spinlock lock
§ struct rbt tree
§ struct id_range reserve_pool[ID_RANGE_RESERVE_COUNT]
§ struct id_range *reserve_free
struct id_space * id_space_init(uint64_t max_id)
source
void id_space_destroy(struct id_space *is)
source
uint64_t id_space_alloc(struct id_space *is)
source
void id_space_free(struct id_space *is, uint64_t id)
source
uint64_t id_space_alloc_range(struct id_space *is, uint64_t count)
source
void id_space_free_range(
    struct id_space *is,
    uint64_t start,
    uint64_t count
)
source
#define ID_RANGE_RESERVE_COUNT 128
source
#define ID_SPACE_INIT
source
Expansion
#define ID_SPACE_INIT \
    (struct id_space) { \
        .reserve_free = NULL \
    }