Objective-C: atom property is fully retrieved

As for the atomic property, then in the Apple documentation this is below:

This means that synthesized accessors ensure that the value is always completely retrieved by the getter method or completely set via the setter, even if the accessors are called from different threads at the same time.

What does “fully restored” or “fully installed” mean? Why is "fully restored" or "fully installed" insufficient to ensure thread safety?

Note. I know that there are many posts regarding atomicity on SO, please do not post this as a duplicate unless the ticket specifically addresses the issue above. After reading the posts, I still do not fully understand nuclear property.

+4
source share
3 answers

, / . , , , , . , , , . , , , . , , , , / / .

, , , . , , , .

, . , . , , - , - . , , , , . , , , .

+2

" " " " , "0x11111111" "0x22222222". , "0x11112222" "0x11221122". atomic .

// Thread 1
while (true) x = 0x11111111;

// Thread 2
while (true) x = 0x22222222;

// Thread 3
while (true) printf("0x%x\n", x);
+1

, , . , .

, , , , , , . , , ( - ), .

, , , .

0

Source: https://habr.com/ru/post/1526386/


All Articles