shared - i need it to be useful

Stanislav Blinov stanislav.blinov at gmail.com
Wed Oct 17 19:03:21 UTC 2018


On Wednesday, 17 October 2018 at 18:46:18 UTC, Manu wrote:

> I've said this a bunch of times, there are 2 rules:
> 1. shared inhibits read and write access to members
> 2. `shared` methods must be threadsafe
>
>>From there, shared becomes interesting and useful.

Oh God...

void atomicInc(shared int* i) { /* ... */ }

Now what? There are no "methods" for ints, only UFCS. Those 
functions can be as safe as you like, but if you allow implicit 
promotion of int* to shared int*, you *allow implicit races*.


More information about the Digitalmars-d mailing list