Re: std::atomic<> for double

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2012/4/21 Marc Glisse:
> double isn't an integral type, so you can't do much more than store, load,
> exchange and compare_exchange_{weak,strong}. For your case, you get the
> double value from the atomic, increment it, then use compare_exchange to
> store that new value in the atomic *if the atomic hasn't changed in the
> meantime*, and if the atomic has changed, try again. Note that the
> comparison is done with memcmp, not ==, which for double could be different.
>
> example from the standard:
>
> expected = current.load();
> do {
>  desired = function(expected);
> } while (!current.compare_exchange_weak(expected, desired));
>
>
> Note that there are already books available to learn these things, search
> for instance for "C++ Concurrency in Action".

Thank you for your answer!



-- 
Regards,
  niXman



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux