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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu May 31 11:17:58 PDT 2012


On 5/31/12 5:19 AM, deadalnix wrote:
> The solution consisting in passing a delegate as parameter or as
> template is superior, because it is now clear who is in charge of the
> synchronization, reducing greatly chances of deadlock.

It can also be a lot clunkier for certain abstractions. Say I want a 
ProducerConsumerQueue. It's much more convenient to simply make it a 
synchronized class with the classic primitives, instead of primitives 
that accept delegates etc.

Nevertheless I think there's merit in this idea. One thing to point out 
is that the idiom can easily be done today with a regular class holding 
a synchronized class private member.

So we got everything we need.


Andrei


More information about the Digitalmars-d mailing list