synchronized - shared but actually useful

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Oct 31 10:25:52 UTC 2018


On Wednesday, October 31, 2018 3:36:22 AM MDT FeepingCreature via 
Digitalmars-d wrote:
> There doesn't seem to be a trait to detect a synchronized class.
> Having learnt that synchronized classes are actually mostly
> implemented (how did I not know this! Though I still think the
> fact that they can be impure is an issue, but that's statically
> checkable at least),

synchronized classes are only partially implemented, and the key feature
that they implicitly remove the outer layer of shared in their member
functions is one of the things that isn't implemented. I don't know exactly
what is and isn't implemented at the moment. I recall restrictions on
accessing member variables from outside the class being implemented, but I
don't think that anyone has really sat down and worked through what's left
to do (though I could be wrong - I don't follow the list of dmd PR's
closely). I don't see why the member functions being impure is a problem.
Direct access to the member variables is protected, and I don't think that
you're supposed to be allowed to pass a pointer to a member variable out of
the class, but you can escape stuff that the member variables refer to, so I
don't see why it matters particularly that they would have access to
module-level variables. synchronized classes really only protect the stuff
that sit directly inside the class itself, not what the class' member
variables refer to. If they were to fully protect everything inside of it,
then you couldn't really pass anything in or out of it.

- Jonathan M Davis





More information about the Digitalmars-d mailing list