On Sunday, 16 March 2014 at 04:08:15 UTC, Andrei Alexandrescu
wrote:
D1's approach to multithreading was wanting. D2 executed a big
departure from that with the shared qualifier and the
default-thread-local approach to data.
We think this is a win, but D2 inherited a lot of D1's
thread-related behavior by default, and some of the rules
introduced by TDPL (http://goo.gl/9gtH0g) remained in the "I
have a dream" stage.
Fixing that has not gained focus until recently, when e.g.
https://github.com/D-Programming-Language/dmd/pull/3067 has
come about. There is other more stringent control of shared
members, e.g. "synchronized" is all or none, "synchronized"
only makes direct member variables unshared, and more.
This will statically break code. It will refuse to compile code
that is incorrect, but also plenty of code that is correct; the
compiler will demand extra guarantees from user code, be they
in the form of casts and stated assumptions.
I believe this is a bridge we do need to cross. One question is
how we go about it: all at once, or gradually?
Andrei
I still have zero understanding of what "synchronized" is
supposed to mean an only vague guesses about "shared". Probably
have never used either of those apart of "shared static this()"
module constructors. Having some examples of how code is supposed
to behave and what will break can help reason about it.