Improving the waitFor and waitUntil macro definitions

The following set functions found in the spark_wiring_system.h file all seem to have trouble with testing conditions that aren't simple static or standalone functions due to the lack of captures in their definitions.

#define waitFor(condition, timeout) System.waitCondition([]{ return (condition)(); }, (timeout))
#define waitUntil(condition) System.waitCondition([]{ return (condition)(); })
#define waitForNot(condition, timeout) System.waitCondition([]{ return !(condition)(); }, (timeout))
#define waitUntilNot(condition) System.waitCondition([]{ return !(condition)(); })

I'm wondering if these could be improved by simply adding the implicit capture [=] to the definitions to allow for more use cases. My question has to do with whether or not this could lead to any sort of issues that I might not be seeing due to my limited knowledge of how this actually works in capturing local instances of objects.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.