Advertisement
asan13

Untitled

Oct 13th, 2017
1,302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.56 KB | None | 0 0
  1. import std.stdio;
  2. import std.algorithm.searching : find;
  3. import std.concurrency;
  4. import core.atomic;
  5.  
  6. shared int x;
  7.  
  8. int main(string[] argv)
  9. {
  10.     x += 1;   // здесь варнинг
  11.     writeln(x);
  12.  
  13.     atomicOp!"+="(x, 10);
  14.     writeln(x);
  15.  
  16.     return 0;
  17. }
  18.  
  19. /*
  20. Performing "debug" build using dmd for x86_64.
  21. test ~master: building configuration "application"...
  22. source/app.d(10,5): Deprecation: read-modify-write operations are not allowed for shared variables. Use core.atomic.atomicOp!"+="(x, 1) instead.
  23. Linking...
  24. Running ./test
  25. 1
  26. 11
  27. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement