I found the following code: there is always:
std::atomic<A> is lock free? false
std::atomic<B> is lock free? true
This is the code:
struct A { int a[100]; };
struct B { int x, y; };
int main()
{
std::cout << std::boolalpha
<< "std::atomic<A> is lock free? "
<< std::atomic<A>{}.is_lock_free() << '\n'
<< "std::atomic<B> is lock free? "
<< std::atomic<B>{}.is_lock_free() << '\n';
}
I don’t understand how the second specialized atomic type of the structure is blocked and the 1st specialized atomic type cannot be blocked?
Thanks in advance.
source
share