vendredi 1 septembre 2017

How can the struct specialized atomic type be lock free?

I found the following code, the out put is always:

std::atomic is lock free? false std::atomic is lock free? true

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 do not understand how can the second struct specialized atomic type be lock free and the 1st specialized atomic type cannot be lock free?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire