[dmd-concurrency] synchronized, shared, and regular methods inside the same class

Andrei Alexandrescu andrei at erdani.com
Mon Jan 4 15:45:47 PST 2010


Jason House wrote:
> On Jan 4, 2010, at 12:00 PM, Andrei Alexandrescu <andrei at erdani.com>
> wrote:
> 
>> 
>> ... subject to the "tail-shared" exemption that I'll discuss at a 
>> later point.
> 
> I wish you'd stop giving teasers like that. It feels like we can't
> have a discussion because a) you haven't tried to share your
> perspective b) you're too busy to have the conversation anyway
> 
> I'm probably way off with my impression...

In the words of Wolf in Pulp Fiction: "If I'm curt it's because time is
of the essence".

The tail-shared exemption is very simple and deducible so I didn't think
it was necessary to give that detail at this point: inside a
synchronized method, we know the current object is locked but the
indirectly-accessed memory is not. So although the object's type is
still shared, accessing direct fields of the object will have their
memory barriers lifted. This is just a compiler optimization that
doesn't affect semantics.

and:

> Sadly, this is a side effect of a simplistic handling of shared.
> Shared is more like "here be dragons, here's an ice cube in case one
> breaths fire on you". Nearly all protection / correctness
> verification are missing and left for D3 or beyond. Message passing
> lets shared aware code remain in the trusted code base...

This is speculation. Please stop it. We plan to define clean semantics
for shared.


Andrei


More information about the dmd-concurrency mailing list