On 08-Jul-2015 15:39, wobbles wrote:
On Wednesday, 8 July 2015 at 12:21:22 UTC, Jonathan M Davis wrote:
On Wednesday, 8 July 2015 at 11:02:19 UTC, Márcio Martins wrote:
[...]


Interesting, so the main pain of using shared is the requirement to cast
away the shared whenever you want to work on the data in a synchronized
block.

Is there any links do you know to the old conversations on what
solutions are there for this?

My first thought is using the 'with' keyword.
shared int mySharedInt;
synchronised(mutexObj) with (mySharedInt){
     // any references to mySharedInt in this block are implicitly
converted to non-shared
}

It's good convention but still convention - who guarantees that the right mutex was locked? The locking protocol is outside of the competence of the compiler.

However there are synchronized _class_-es that might play nice with shared b/c very access to them is guarded by built-in mutex.

--
Dmitry Olshansky

Reply via email to