thread-safe shared field access

2016-06-30 Thread jj75607 via Digitalmars-d-learn
For example I have a shared from different threads variable. What piece of code is correctly thread-safe? First: shared class A { shared(int) x; void test1() { x = 10; x += 5 writeln(x); } } Or second: import core.atomic; shared c

Re: thread-safe shared field access

2016-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/16 10:10 AM, jj75607 wrote: For example I have a shared from different threads variable. What piece of code is correctly thread-safe? First: shared class A { shared(int) x; Note, no need to mark x shared. 'A' implicitly shares everything. void test1() {