jeudi 19 avril 2018

c++ Creating a new thread from a member function and moving the object and the entire

according to the code bellow, is myClass1 object and myClass2 obj (which is the myClass1 object's member ) moving to the new thread with their memory(Like std::move()) ?

class myClass1{

  public:
   myClass2 obj;

    myClass1(myClass2 * obj) {
        this.obj = obj;

    }
    thread spawn() {
        return std::thread([this] { this->Run(); });
    }
    void Run() {
        cout << "new thread" << endl;
    }
}
int main(){
  myClass1 object(new myClass2);
  object.spawn();
 ........
 ........
}

Aucun commentaire:

Enregistrer un commentaire