Allow environment capture in lambda callbacks#19
Allow environment capture in lambda callbacks#19Aasim-A merged 3 commits intoAasim-A:masterfrom c-jiph:master
Conversation
|
Hi Jacob, thanks for the PR, my concern is that this may not work with |
|
Ah, you are absolutely right. The project I was working on is actually for an Arm-based Arduino board, not AVR. After checking I see STL is not available in the Arduino IDE for AVR boards. The AVR compiler is still fully gcc with C++ backed, so I was able to update my PR to make this work without STL. The change is quite a bit more involved though. Essentially I've created a very simple replacement for It's not ... beautiful, but seems to work and I've verified it on an Arduino Uno board. The most annoying part is not having things like What do you think? |
|
@Aasim-A any comments? |
|
Works perfectly on an ESP32 |
|
Hi, sorry I've been super busy lately, I'll look more into this and try to merge it into the library. Thanks again for the PR |
|
@c-jiph Sorry this took this long, thanks a lot for putting the time to implement this 🙂 |
Thank you for making this library, it's been really helpful for a small project of mine.
This PR adds the ability to capture variables in lambdas used as timer callbacks. For example:
Without something like this PR, the above will fail with an error like:
Note this actually fixes the existing example
CancelTimeoutExample.inowhich currently does not compile in master.I've also included a macro option
LITE_CALLBACK_SUPPORTwhich enables the old implementation which will save a small amount of code and data storage for highly constrained projects.