Are atomic variables lock-free?

The standard does not specify if atomic objects are lock-free. On a platform that doesn’t provide lock-free atomic operations for a type T, atomic<T> objects may be implemented using a mutex, which wouldn’t be lock-free. In that case, any containers using these objects in their implementation would not be lock-free either. The standard does provide … Read more

How to declare a vector of atomic in C++

As described in this closely related question that was mentioned in the comments, std::atomic<T> isn’t copy-constructible, nor copy-assignable. Object types that don’t have these properties cannot be used as elements of std::vector. However, it should be possible to create a wrapper around the std::atomic<T> element that is copy-constructible and copy-assignable. It will have to use … Read more

Is rename() atomic?

Yes and no. rename() is atomic assuming the OS does not crash. It cannot be split by any other filesystem op. If the system crashes you might see a ln() operation instead. Also note, when operating on a network filesystem, you might get ENOENT when the operation succeeded successfully. Local filesystem can’t do that to … Read more

Avoid duplicate POSTs with REST

Another solution that’s been proposed for this is POST Once Exactly (POE), in which the server generates single-use POST URIs that, when used more than once, will cause the server to return a 405 response. The downsides are that 1) the POE draft was allowed to expire without any further progress on standardization, and thus … Read more

Which std::sync::atomic::Ordering to use?

I’m not an expert on this, and it’s really complicated, so please feel free to critique my post. As pointed out by mdh.heydari, cppreference.com has much better documentation of orderings than Rust (C++ has an almost identical API). For your question You’d need to use “release” ordering in your producer and “acquire” ordering in your … Read more

How to perform atomic operations on Linux that work on x86, arm, GCC and icc?

Projects are using this: http://packages.debian.org/source/sid/libatomic-ops If you want simple operations such as CAS, can’t you just just use the arch-specific implementations out of the kernel, and do arch checks in user-space with autotools/cmake? As far as licensing goes, although the kernel is GPL, I think it’s arguable that the inline assembly for these operations is … Read more

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