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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue May 29 14:31:38 PDT 2012


On 5/29/12 1:32 AM, deadalnix wrote:
> I already did some comment about this.
>
> Making any object synchronization is a very bad design decision. It is
> deadlock prone, it is liquid lock prone, it cause an overhead on any
> object, and even worse, it is useless most of the time as D promote
> thread locality (which is very good).

Actually I think such a characterization is superficial and biased to 
the extent it becomes wrong.

Locks are deadlock-prone by design, whether used with objects or with 
classic procedural programs. In fact they are better confined to objects 
because the association between the protected data and the 
synchronization object is clear.

> OOP and concurrency are 2 orthogonal topics, and should be handled as
> such.

Well there would be active objects that contradict that. But really it 
is very natural to encapsulate together some data along with the mutex 
that must be acquired to manipulate it. There are known issues with 
inheritance, but they are not introduced by the approach, only exposed 
by it.


Andrei


More information about the Digitalmars-d mailing list