|
|
|
|
|
by FFFXXX
300 days ago
|
|
I think you are quoting from https://learn.microsoft.com/en-us/dotnet/api/system.threadin... "In C#, using the volatile modifier on a field guarantees that every access to that field is a volatile memory operation" This makes it sound like you are right and the volatile keyword has the same behaviour as the Volatile class which explicitly says it has acquire-release ordering. But that seems to contradict "The volatile keyword doesn't provide atomicity for operations other than assignment, doesn't prevent race conditions, and doesn't provide ordering guarantees for other memory operations." from the volatile keyword documentation? |
|
https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
"When a field_declaration includes a volatile modifier, the fields introduced by that declaration are volatile fields. [...] For volatile fields, such reordering optimizations are restricted: