Christopher Wright wrote: > Brad Roberts wrote: >> An interesting side effect of these changes is that thread startup >> cost is going to increase. Yet more reasons to avoid globals and >> global initialization. >> >> -- Brad > > It'll further promote use of threadpools. This isn't terribly safe > because the globals for that thread are left in some arbitrary state -- > yet more reason to avoid globals.
Introspection would solve this. Just define a function initThread(), then use introspection to iterate over the module graph, find all static functions by that name, and call them whenever a thread needs to be cleaned up.