-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid circular #include dependence for PolledTimeout #7356
Conversation
I see multiple issues with this PR, in that it works against PRs from me - either those still pending, or by undoing performance improvements in already merges PRs. |
To start off, though, PolledTimeout is good for stackless coroutine programming, but replacing delay(), intended in Arduino to be shimmed by multitasking libraries, prominently here from my POV the CoopTask implementation, breaks that cooperative multitasking model of stackful coroutines.
incorrectly claims that |
The change from |
Dear dok-net, I'm sorry to know that you see so many issues in this trivial PR.
Can you name them and show how performances are degraded ?
Lots of snippets seen in issues of this repository use that kind of
That is a rename I can make in this PR, not a problem.
This is a supposition from your part.
It is targetted for version 3.0.0 so there is plenty of time. You seem to see a general failure or much complexity where this PR simply adds an include file and imports a global conflictless namespace. I'm sorry to admit that I have a general failure in trying to understand what "separation-of-concern failure" means here. You are free to explain to not use polledTimeout in your library's documentation. But you cannot claim that polledTimeout is counter-productive nor not needed in the provided example in OP. It was also originally made for that purpose. |
Dear @d-a-v, I have no strong feelings about the central change underlying this PR:
What does cause me some concern, though, is that there are a handful of changes in this PR, that are unrelated to that namespace matter. That is what I refer to as separation of concern issue. If you could split it into individual PRs, it would make it easier to discuss the issues. To get you started on an obvious problem, I think there's an undetected compile-time failure caused by one of the changes. Where you add an implementation of |
Furthermore, the example code change you give in this PR, labelled as "transformation", is in fact a completely different style of programming for all except the most trivial "Hello world" program code. I'm in no way passing judgement on whether commonplace AVR Arduino-like code using |
@dok-net I'm sure I have seen this or even done this on AVR before, not you ? // declaration: unsigned long for lastTime and intervalMs
if (millis() - lastTime > intervalMs) {
lastTime += intervalMs;
digitalWrite(LED_BUILTIN, 1 - digitalRead(LED_BUILTIN));
} That makes me think that we could port the polledTimeout library to be arduino compatible on all architectures, so we could on a pro mini // declaration: periodicMs doItNow(intervalMs);
if (doItNow) {
digitalWrite(LED_BUILTIN, 1 - digitalRead(LED_BUILTIN));
} What do you think ? |
@d-a-v No objections, just note that this never had anything to do with delay in the first place. It's a different programming paradigm. |
What's striking me in this PR is that it is calling |
The goal of this PR is to make it easy to use, as presented in the OP. |
I can understand why it may be a good thing, so I won't object as long as you do consider the implications of calling Still there may be name conflicts if some function has the same name (or function signature) in existing projects which also occur in this name space. |
Yes, there is a risk of a name collision with If the |
libraries/esp8266/examples/BlinkPolledTimeout/BlinkPolledTimeout.ino
Outdated
Show resolved
Hide resolved
@devyte I'll let you verify changes following your review. |
edit / change:
This PR removes
#include <Arduino.h>
fromPolledTimeout.h
thus avoid circular dependencies in some cases.(cf. last line from OP below)
Title is changed accordingly.
OP:
Using
delay()
in the main loop is not efficient in the esp8266 arduino core.PolledTimeout has beed added a while ago to help users avoiding it.
PolledTimeout is not included by default and being hidden in a deep namespace hierarchy makes its access difficult to the average arduino user.
This PR brings it at top level. It is now easier for a user to understand and remember how to transform
to
or
All other useful classes in PolledTimeout are also available.
Documentation for PolledTimeoud is in an example (updated in this PR)
Also adding
::resetAndSetExpired([period])
to mark a periodic to be triggered at next check, and optionally change its period.All other changes are due to circular inclusions with Arduino.h.