-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
In Thread.VolatileRead remarks:
In C#, using the volatile modifier on a field guarantees that all access to that field uses VolatileRead or VolatileWrite
This is incorrect, because volatile
keyword does not actually use these methods, but only causes all field access instructions to be volatile operations. I was going to submit a pull request similar to #2503 , but then i realized it won't really help, because this article is still missing the real use cases for Thread.VolatileRead/Write and how are these methods related to similar methods of Volatile class. Given that this statement is duplicated many times, i decided to open issue first to disscuss how it should be changed.
As I understood, In .NET Core Thread.VolatileRead/Write are just shortcuts to Volatile.Read/Write, and in .NET Framework they are older inefficient variant of them (use full memory barrier instead of half-barrier). Should documentation mark these methods as not recommended for use and point to Volatile class?
Related: https://github.com/dotnet/dotnet-api-docs.ru-ru/issues/22