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

Alex Rønne Petersen alex at lycus.org
Tue May 29 10:01:00 PDT 2012


On 29-05-2012 18:57, Alex Rønne Petersen wrote:
> On 29-05-2012 18:41, Jess wrote:
>> 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?
>>
>
> druntime is the low-level runtime library of D. This discussion is about
> high-level class design.
>

I should also add that the reason I started this thread was to prevent 
common locking errors induced by the anti-patterns synchronized causes. 
If you're calling *anything* in the core.memory module, I sure hope you 
know what you're doing in general.

I really don't think these two issues are connected at all.

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d mailing list