shared - i need it to be useful

aliak something at something.com
Thu Oct 18 17:10:03 UTC 2018


On Thursday, 18 October 2018 at 16:31:02 UTC, Stanislav Blinov 
wrote:
> So again,
>
> void atomicInc(shared int*); // is "not safe", but
> void struct_Atomic_int_opUnary_plus_plus(ref shared Atomic); // 
> is "safe"
>
> just because latter is a "method". And that, by you, is 
> hunky-dory? Whether it's a method or a free function, it's 
> written to work on *shared* data. Of course it wouldn't be safe 
> if you allow any non-shared data to become shared without the 
> programmer having a say in this.

Out of curiosity, when it comes to primitives, what could you do 
under MP in void "atomicInc(shared int*)" that would be 
problematic?

void atomicInc(shared int*) {
   // i.e. what goes here?
}




More information about the Digitalmars-d mailing list