lundi 31 août 2020

C++ What atomic operations we can use on trival user defined data type

I am trying to understand std::atomic types and atomic operations. Below is my code:

#include <atomic>
#include <iostream>

class A
{
public:
    int x;
    void Show() {}
};

int main()
{
    std::atomic<A> fooA;
    // fooA.Show(); -- gives me std::atomic<A> has no member Show()
}

What are the atomic operations we can do when we define a user type - like Mtype.load() etc - how can we use Mtype with load() atomic operations - where load atomically obtains the value of the atomic object?

Aucun commentaire:

Enregistrer un commentaire