dimanche 4 juin 2017

Calling memberfunctions in paralell

I try to use std::thread to run calls to diferend class members in paralell.

The header file's code is similar to:

class SomeClass {
    drawGui guiDrawer;
public:
    explicit SomeClass (const string someArg);
    ~SomeClass ();
};

In my cpp file I am calling something like that:

std::unique_ptr<Graphics> graphics(img);
this->guiDrawer.drawCPU(graphics); // Definition looks like that: void drawCPU(std::unique_ptr<Graphics> &graphics);
this->guiDrawer.drawRAM(graphics);
this->guiDrawer.drawTime(graphics);

I am now trying to run those 3 calls in paralell but it is not working.

I tried:

std::thread t1(guiDrawer.drawCPU, graphics);

and

std::async(std::launch::async, guiDrawer.drawCPU, graphics);

But both give me errors like C3867 and C2672. I can't figure out what is the problem. I am compileing with VS2015.

Aucun commentaire:

Enregistrer un commentaire