Add methods to check if there's an IRQ handler #764
Merged
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.
Summary
Added methods to check if there's an user-IRQ-handler currently attached.
This PR implements the following feature
Why
..well...first of all...why not?
The HardwareTimer, internally, knows if there's a callback. Exposing this to the user makes no harm.
It's a good C++ programming practice to give a way for an object to expose its status.
Now let's talk about why should it be there.
Imagine a situation in which you want to disable the callback (for example on a channel) leaving the timer running and receiving other interrupts on other channels.
When you have multiple timers and each of them has multiple channels it's difficult to keep track of them all, moreover if they aren't enabled and disabled from the "main" schetch but by some other interrupt handler.
In a situation where you have "multiple sources" of detach/attach this can be cumbersome.
Providing a "zero-cost" (each HardwareTimer knows it already) property which will expose the status of the interrupt handler (present/absent) will make code easier to write and with less bugs.
Validation
Should be good.
Code formatting
Should be good.
Closing issues
Doesn't close any issue but helps programmers to not create new ones.