Why isn’t atomic double fully implemented

std::atomic<double> is supported in the sense that you can create one in your program and it will work under the rules of C++11. You can perform loads and stores with it and do compare-exchange and the like. The standard specifies that arithmetic operations (+, *, +=, &, etc.) are only provided for atomics of “integral … Read more

Is synchronizing with `std::mutex` slower than with `std::atomic(memory_order_seq_cst)`?

Lockfree programming is about progress guarantees: From strongest to weakest, those are wait-free, lock-free, obstruction-free, and blocking. A guarantee is expensive and comes at a price. The more guarantees you want, the more you pay. Generally, a blocking algorithm or datastructure (with a mutex, say) has the greatest liberties, and thus is potentially the fastest. … Read more

How Compare and Swap works

“general pseudo code” is not an actual code of CAS (compare and swap) implementation. Special hardware instructions are used to activate special atomic hardware in the CPU. For example, in x86 the LOCK CMPXCHG can be used (http://en.wikipedia.org/wiki/Compare-and-swap). In gcc, for example, there is __sync_val_compare_and_swap() builtin – which implements hardware-specific atomic CAS. There is description … Read more

C++11 atomic memory ordering – is this a correct usage of relaxed (release-consume) ordering?

Why are you loading the old flags value twice in your CAS loops? The first time is by flags.load(), and the second by the compare_exchange_weak(), which the standard specifies on CAS failure will load the previous value into the first argument, which in this case is flagsNow. According to http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange, “Otherwise, loads the actual value … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)