Generality creep

FeepingCreature feepingcreature at gmail.com
Mon Apr 1 12:28:37 UTC 2019


On Monday, 1 April 2019 at 10:11:04 UTC, Jonathan M Davis wrote:
> On Monday, April 1, 2019 1:08:29 AM MDT FeepingCreature via 
> Digitalmars-d wrote:
>> Uncoupling shared from synchronized at the class level would 
>> make synchronized classes actually usable and useful without 
>> restructuring the entire class for no gain.
>
> How is synchronized unrelated to shared?

In the one way that matters - in practice. :)

I'll be honest; we use synchronized a whole lot and shared in 
maybe ten lines total. How? Well, in the obvious way: void 
method() { synchronized (this) { } }. No shared, no fuss.

I would be surprised if this was not the predominant way of 
synchronizing classes in D in production right now, precisely 
because you *don't* have to bother with shared.

And if you do it that way, invariants are inherently useless.

> The only exception is __gshared, which is only supposed to be 
> used for C globals

I'm sorry, but there's a very great distance here, at least in 
our codebase, between "only supposed to" (C globals) and "what 
it's actually used for" (*any* threadshared globals). Nobody 
wants to touch shared, but we still need threading.



More information about the Digitalmars-d mailing list