Add virtual destructor to thread.h to prevent undefined behavior on destruction. #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the documentation of ArduinoThread one should be able to inherit from the Thread class:
"Inheriting from Thread or even ThreadController is always a good idea. For example, I always create base classes of sensors that extends Thread, so that I can "register" the sensors inside a ThreadController, and forget about really reading sensors, just getting theirs values within my main code. Checkout SensorThread example."
When doing this in Eclipse I get an error like "Class 'XXX' has virtual method 'run' but non-virtual destructor"
according to this:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#discussion-make-base-class-destructors-public-and-virtual-or-protected-and-nonvirtual
a base class should define a public virtual destructor otherwise destruction via a pointer to a base class would lead to undefined behavior (and a possible memory leak as the inherited destructor isn't guaranteed to be called).
...and a disclaimer: I'm originally a Java guy and has just recently started to learn C++. I might have gotten everything completely wrong :)