synchronized (this[.classinfo]) in druntime and phobos

Jess Jess.Sandgren at hotmail.com
Tue May 29 09:41:03 PDT 2012


On Monday, 28 May 2012 at 23:55:04 UTC, Alex Rønne Petersen 
wrote:
> On 29-05-2012 01:46, Jonathan M Davis wrote:
>> On Tuesday, May 29, 2012 01:38:25 Alex Rønne Petersen wrote:
>>> I should probably add that Java learned it long ago, and yet 
>>> we adopted
>>> it anyway... blergh.
>>
>> The "lesson learned" from Java that TDPL enumerates is the 
>> mistake of having
>> synchronized on functions rather than entire classes, but 
>> clearly even that is
>> currently TDPL-only and not actually properly implemented yet.
>>
>> - Jonathan M Davis
>
> But synchronized on entire classes is exactly equally flawed... 
> the fundamental problem is still that they synchronize on a 
> public resource.

Sorry, I don't quite follow...

1) locking on a public resource
=> BAD, high risk.

2) Adding GC.callLocked(), allowing a generic delegate to claim 
the GC lock
https://github.com/D-Programming-Language/druntime/pull/213
=> no-brainer, i.e. no risk?



More information about the Digitalmars-d mailing list