Thread safe property access #46318
-
Is there any guarantee that property access always reads the field from memory ? E.g. this code from .NET. internal bool Disposed => _disposed != 0; My assumption that JIT can optimize the property access into a variable access or into register and then the processor might cache its value. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
I don't believe properties do anything special here. If you need this guarantee you should mark |
Beta Was this translation helpful? Give feedback.
-
You might be aware of this, but I still want to point out that |
Beta Was this translation helpful? Give feedback.
-
Also answered by @gfoidl and @PathogenDavid |
Beta Was this translation helpful? Give feedback.
Also answered by @gfoidl and @PathogenDavid