Only const or immutable class thread local variables are allowed

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sun Dec 8 22:42:28 PST 2013


On 09/12/13 01:24, Ali Çehreli wrote:
> On 12/08/2013 02:40 PM, qznc wrote:
>
>> I understand you are talking about the "Singleton" design pattern.
>> You might want to look how std.parallelism does it with the default
>> global thread pool.
>>
>> https://github.com/D-Programming-Language/phobos/blob/master/std/parallelism.d#L3261
>
> David Simcha presented it as a D-specific pattern and explained how D avoids at
> least one of the bugs of double-checked locking:

(i) That's very cool :-D

(ii) I still think it's not what I want.  The "static" class instance doesn't 
need to be globally global, I want the default thread-local storage as per the 
existing std.random.rndGen.  Hence the solution I arrived at, but which I'm sure 
could be improved.


More information about the Digitalmars-d-learn mailing list