jeudi 22 juillet 2021

what happens to 'this' when an object is in destruction [closed]

# A simplified class
class A {
    Object obj1;
    Object obj2;
    void submitTaskToAnotherThread([this](obj1.doSomething()));
}

Assume A is in destruction, obj2 will not be destructed until all submitted tasks are finished

So when the other thread is executing the submitted task, will it be able to always access 'this'? What could possibly happen?

Aucun commentaire:

Enregistrer un commentaire