Currently, we create a bunch of refs associated with our userdata (descriptors, timers, ZeroMQ watchers). Now that lua_newuserdatauv()
exists, we could instead create userdata that way and keep the relevant Lua values alongside the C structures. struct watcher
in lua_zmq.c
in fact only exists to hold three lua values.
I imagine each type could have an enum of uservalue indices e.g.
enum watcher_uservalue {
WATCHER_USERVALUE_SOCKET,
WATCHER_USERVALUE_IN,
WATCHER_USERVALUE_OUT,
NUM_WATCHER_USERVALUES
};