[Issue 14251] synchronized (mtx) doesn't check attributes (pure, const)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Sep 22 09:29:51 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=14251

--- Comment #21 from Martin Nowak <code at dawg.eu> ---
(In reply to Andrei Alexandrescu from comment #19)
> > Just look at core.sync, none of the methods can be implemented const or
> > pure, still they get called from const/pure code.
> 
> That's not a problem, the runtime is expected to contain nonportable code.

I'd say the real attribute problem is not the automatic mutex generated for
`synchronized (instance)`, b/c we can control how that behaves. But b/c it's
possible to assign an arbitrary Object.Monitor implementation, people can run
very different Mutex implementations.
As usual there is no deprecation path for adding attributes to an
interface/base-class, and the last time we tried to make Object.Monitor
nothrow, we broke valid use cases in vibe.d that we're using async/event-based
mutexes.

Now this bug report is about the effect that _d_monitorenter/exit do call any
Mutex implementation w/o checking for attributes.
We had so many problems w/ attributes and old C compiler-runtime APIs, and it
always boils down to this:

Forcing everyone to use the same attributes is too limiting/breaks code, let's
replace the old C API w/ templated library code.

--


More information about the Digitalmars-d-bugs mailing list