Add remove(int) functionality to clear long running tasks. - #1
Open
sdesalas wants to merge 2 commits into
Open
Conversation
remove(int) functionality to allow clearing running tasks.sdesalasforce-pushed
the
master
branch
3 times, most recently
from
March 24, 2025 21:11
44cf421 to
32847f6Compareremove(int) functionality to allow clearing running tasks.remove(int) functionality to clear long running tasks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hiya Moin 👋 .
I've been using your library on an arduino-clone AVR project I started recently. Thanks for making it available.
While applying the async/scheduled tasks to my code I realized that there was some functionality missing that I needed. The ability to cancel long-running tasks.
So I exposed
remove(int taskId)(previously private methodremoveTask(int taskId)) to allow cancelling existing tasks by id (wether its repeated task or otherwise). And also added the ability to returninttask ids at creation time (usingonce()orrepeat()methods) so they could be cancelled later.I also changed the
taskIdtype frominttounsigned intto make all task Ids positive. This is probably not critical since without the change thetaskId++will just wrap-around due to overflow when you hit 32K and start asigning negative task Ids. But it makes things a bit easier to understand and use, specially for logging purposes.I thought I'd let you know about my changes and give you a chance to merge them upstream if you think them useful. There is also a couple of corrections to the README to reflect the above, as well as the use of
.loop()instead of.run()which was incorrect originally.Kind Regards,
Steven