Iterating over thread local storage variables

sigod via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Mar 11 10:53:54 PST 2016


On Friday, 11 March 2016 at 18:45:13 UTC, Anonymouse wrote:
> On Friday, 11 March 2016 at 17:33:43 UTC, sigod wrote:
>> On Friday, 11 March 2016 at 17:03:38 UTC, Anonymouse wrote:
>>> On Friday, 11 March 2016 at 15:21:38 UTC, maik klein wrote:
>>>>                 [...]
>>>
>>> As a drive-by comment, mind that there is a race there. 
>>> _instantiated may have been set after the if statement but 
>>> before the synchronized block. You have to test it again 
>>> inside.
>>
>> That's why inside of `synchronized` block you can see `if 
>> (!instance_)`.
>
> It does, yes, but it also calls instance_.tls.insertBack 
> unconditionally. To illustrate: 
> http://dpaste.dzfl.pl/8f3e78f3265a7
>
> Apologies for derailing.

Indeed. You're right. I didn't even look at `instance_.tls...` 
line.

I guess `insertBack` just need to be moved inside of `if 
(!instance_)` scope.


More information about the Digitalmars-d-learn mailing list