Difference between __gshared and shared.

wobbles via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 8 05:39:58 PDT 2015


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
}


More information about the Digitalmars-d mailing list