brian-lau / MatlabProcessManager

Matlab class for launching and managing asynchronous processes
BSD 2-Clause "Simplified" License
22 stars 12 forks source link

Error in destructor #7

Open ChristianStadelmann opened 1 year ago

ChristianStadelmann commented 1 year ago

In my code, I create a processManager object. When it goes out of scope, i.e., when Matlab decides to call the destructor, I sporadically¹ see this error message:

The following error was caught while executing 'processManager' class destructor:
Error using timer/stop (line 34)
Invalid timer object. This object has been deleted and should be removed from your workspace using CLEAR.

Error in processManager/delete (line 483)
               stop(self.pollTimer);

I guess that this is a race condition between the destructor and the timer's stop() function calling pollTimerStop().

Would it help to turn pollTimerStop() into a non-static function which not only deletes the timer at the end, but also sets this.pollTimer = [];?


¹ sporadically in this context means something like once in 100 executions.