Le 30/05/2012 21:25, Alex Rønne Petersen a écrit :
On 30-05-2012 21:12, Andrei Alexandrescu wrote:
On 5/30/12 12:03 PM, Steven Schveighoffer wrote:
On Wed, 30 May 2012 14:32:59 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:
On 5/30/12 10:47 AM, Steven Schveighoffer wrote:
Yes, you can just use a private mutex. But doesn't that just lead to
recommending not using a feature of the language?
I don't think so. Synchronized classes are the unit of scoped locking
in D. If you want to do all scoped locking internally, make the class
private.
Maybe you didn't read thoroughly the first part of my post (the example
that shows a deadlock that is easily preventable if the mutex isn't
exposed).
The mutex is not exposed.
I'm trying really hard to not to be rather impolite here, but I don't
know how else to put it: You seem to be the only one who subscribes to
this definition of "exposed". I like to think that there are varying
degrees of exposing resources in programming. The mutex may not be
directly exposed in the sense that you can obtain a reference (though in
reality in all compiler implementations, you can), but it is exposed in
the sense that you can lock and unlock it, which is a mutation of state
and program flow.
I think we need to set aside this matter about what exposing something
really means. The mere fact is that you can lock and unlock the mutex of
any object.
Expliciting terms is always useful, even if it seems sometime irritating.