Wrt. threadlocal by default: shared module constructors
downs
default_357-line at yahoo.de
Fri May 15 03:09:11 PDT 2009
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.
More information about the Digitalmars-d
mailing list