| git.druid.rocks | index | militantprogrammer | astral_canvas | src/ | lib/ | id.h |
src/lib/id.h
#ifndef LIB_ID_H
#define LIB_ID_H
/*
* Widget id pool (internal).
*
* Public Widget.id values come from here. 0 is reserved for the window
* page and is never allocated. Recycled ids go onto a free list so a
* destroyed widget’s id can be reused.
*
* libAllocId is called from the API/main thread when creating a handle
* to return to the app. libFreeId is called from the worker when a node
* is destroyed. One mutex covers both.
*/
/* Create the mutex and empty free list. Returns 0 or -1. */
int idPoolInit(void);
/* Tear down the pool. Does not walk the widget tree. */
void idPoolDestroy(void);
/*
* Next unused id, or a recycled one. Returns 0 if the pool is dead or
* unsigned short would wrap (treat as failure; do not use as a widget).
*/
unsigned short libAllocId(void);
/* Return id to the free list. id 0 is ignored. */
void libFreeId(unsigned short id);
#endif