Re: c# - Interlocked.Exchange and value types

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Off topic, but why would you want to use the Interlocked.XXX methods
for comparing and assigning enum values? Declaring the variable as
volatile should do the job, if I read the docs correctly. The CLR
guarantees that any operation on type with size less than native ints,
is atomic, so why would you want to do Intelocked.Equals and Exchange?

Regards
Senthil

.



Relevant Pages

  • Re: Interesting GCC optimization, but is it legal if POSIX thread support is claimed?
    ... particular object is not, in fact, volatile. ... Otherwise, not declaring ... object is identified as such to the compiler - the compiler is free to ... execution paths, then that function is free to write to that same ...
    (comp.programming.threads)
  • Re: Why is the kfree() argument const?
    ... volatile No cacheing through this lvalue: each operation in the abstract semantics must ... Since the content of the referenced object is unlikely to be declared volatile, ... Or maybe there is a rationale for never declaring kmalloc to have the ...
    (Linux-Kernel)
  • Re: volatile
    ... It has a similar effect to declaring a member function "const": ... The "this" pointer will point to a "volatile"-qualified equivalent ... Since it knows that foo was not changed from its initial value ... In the above example, foo is now a pointer to volatile int, whose ...
    (comp.lang.cpp)
  • Re: can demo
    ... Register GSR is the "Global Controller Status and Error Counters" ... - At least one requested transmission has not been ... declaring the register as volatile is good practice. ...
    (comp.arch.embedded)
  • Re: Is it AVR-GCC bug?
    ... >>To avoid GCC optimization code you should declare timerDebounce variable ... Declaring it volatile will. ...
    (comp.arch.embedded)