On 7/11/20 6:15 AM, Arafel wrote:

Because the system don't know if just this lock is enough to protect this specific access. When you have multiple locks protecting multiple data, things can become messy.

Yes.


What I really miss is some way of telling the compiler "OK, I know what I'm doing, I'm already in a critical section, and that all the synchronization issues have been already managed by me".

You do. It's a cast.

Within this block, shared would implicitly convert to non-shared, and the other way round, like this (in a more complex setup with a RWlock):

```
setTime(ref SysTime t) shared {
    synchronized(myRWMutex.writer) critical_section {  // From this point I can forget about shared
         time = t;
     }
}
```

This isn't checkable by the compiler.

You could accidentally end up referencing shared things as unshared when the lock is unlocked. If you remove shared, you need to know and understand the consequences, and the compiler can't help there, because the type qualifier has been removed, so it's not aware of which things are going to become shared after the lock is gone.

-Steve
  • Re: how to assign to shar... mw via Digitalmars-d-learn
    • Re: how to assign to... mw via Digitalmars-d-learn
      • Re: how to assig... Kagamin via Digitalmars-d-learn
        • Re: how to a... mw via Digitalmars-d-learn
          • Re: how ... mw via Digitalmars-d-learn
          • Re: how ... Steven Schveighoffer via Digitalmars-d-learn
            • Re:... mw via Digitalmars-d-learn
              • ... Steven Schveighoffer via Digitalmars-d-learn
              • ... Jonathan M Davis via Digitalmars-d-learn
              • ... Arafel via Digitalmars-d-learn
              • ... Steven Schveighoffer via Digitalmars-d-learn
              • ... Arafel via Digitalmars-d-learn
              • ... Steven Schveighoffer via Digitalmars-d-learn
              • ... Arafel via Digitalmars-d-learn
              • ... Kagamin via Digitalmars-d-learn
              • ... Arafel via Digitalmars-d-learn
              • ... Kagamin via Digitalmars-d-learn
              • ... Kagamin via Digitalmars-d-learn
              • ... Arafel via Digitalmars-d-learn
              • ... Dominikus Dittes Scherkl via Digitalmars-d-learn
              • ... Arafel via Digitalmars-d-learn

Reply via email to