On Mon, 14 Sep 2009 07:44:44 -0400, Jason House
<jason.james.ho...@gmail.com> wrote:
Robert Jacques Wrote:
On Sun, 13 Sep 2009 18:08:57 -0400, Jeremie Pelletier
<jerem...@gmail.com>
wrote:
.
Bartosz took the concept one step further: when declared as shared, all
methods are implicitly wrapped in synchronize blocks. He then added a
keyword for more manual, lock-free style programming. But this syntactic
sugar isn't implemented yet.
That is not the design for D2. shared means shared. It is neither meant
to mean synchronized nor lockfree. I worry about optimization
opportunities for shared in D2. There may be way too many memory fences
in synchronized code. Without a mapping of a monitor to what's protected
under a monitor, the compiler/optimizer's hands are tied. At best, every
object will be its own monitor, but that hardly makes any sense...
That is the Java model by the way. And really, no one knows what the
shared design is for D2. The keyword has been added, but it has yet to be
fleshed out. And once you start talking about how to flesh it out and what
kinds of syntactic sugar are wanted/needed you need to start looking at
previous solutions, which is what Bartosz has done in his blog posts. The
specific issue you raise, that of excessive monitors, was addressed using
the concept of unique/mobile objects which are both thread-safe and don't
require locking. However, it appears that this won't make it into D2,
which I feel is a shame.