You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Napi::Value ArrayFireTestAsync(const Napi::CallbackInfo& info) {
Napi::Function callback = info[0].As<Napi::Function>();
// who is going to free up / delete this pointer???
ArrayTestWorker* testWorker = newArrayTestWorker(callback);
testWorker->Queue();
return info.Env().Undefined();
}
It looks like the testWorker is a pointer, but when is it going to be freed up/deleted? The example was no info how to delete this pointer... Is this valid code?
I was just playing with this exact thing last night. If you add the destructor method override in your asyncworker subclass and have it do something like std::cout << "async worker destruction" << std:endl; then you should see it print to the console when it completes its Execute and OnOK methods and is destroyed. I think it is destroyed by default unless you explicitly tell it not to be.
Activity
kevinGodell commentedon Jan 23, 2019
I was just playing with this exact thing last night. If you add the destructor method override in your asyncworker subclass and have it do something like
std::cout << "async worker destruction" << std:endl;then you should see it print to the console when it completes its Execute and OnOK methods and is destroyed. I think it is destroyed by default unless you explicitly tell it not to be.p3x-robot commentedon Jan 23, 2019
wow, thanks, i would have not thought it would be automatic for a pointer. so weird! that's all about my C++ .... 👍
p3x-robot commentedon Jan 23, 2019
i will wait for a little time if someone can explain what is happening... :)
gabrielschulhof commentedon Jan 23, 2019
The object instance does indeed self-destruct. We're adding a
SuppressDestruct()method for cases where self-destruction is undesirable.p3x-robot commentedon Jan 24, 2019
i was working for this kind of response. thank you very much!