While developing hexchat-plugin I ran into a little issue: thread-local storage is currently global.
This is a bit of an issue and it’d be cool to have namespaced TLS.
The namespace is not thread-local, instead it gets shared between threads. But the namespace stores thread-locals efficiently. When the thread exits or the namespace gets destroyed, things get deallocated, also importantly is that there shouldn’t be any locks.
This matters when unloading hexchat plugins. I don’t want the thread locals to carry over or leak.
e.g. load plugin -> make holder -> load a second instance of plugin without loading the first -> make another holder -> use both holders at the same time, each independent of the other -> drop both holders -> unload both instances of the plugin