-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Expunge integer timers #2603
Expunge integer timers #2603
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, but can't test right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functions in tmr_map[]
should be removed as well - tmr.alarm()
and friends don't exist anymore.
Regarding the docs: I'd suggest to group the timer functions as a module subsection. They're currently mixed with tmr.wdclr()
etc. This was ok for the old API, but a dedicated section would improve clarity (e.g. https://nodemcu.readthedocs.io/en/dev/en/modules/net/#netsocket-module).
} | ||
return 0; | ||
timer_t t = (timer_t)luaL_checkudata(L, stack, "tmr.timer"); | ||
if (t == NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosmetic: Not needed since luaL_checkudata()
errors out if supplied with a wrong/no userdata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation at https://www.lua.org/pil/28.2.html disagrees:
Finally, luaL_checkudata checks whether the object at the given stack position is a userdatum
with a metatable that matches the given name. It returns NULL if the object does not have the
correct metatable (or if it is not a userdata); otherwise, it returns the userdata address.
I suppose we could eliminate As to reformatting the docs, sure, makes sense. |
We have been "promoting" the use of |
Expunging the static timers is already forcing Lua Developers to rework existing application code if we want to take advantage of the upcoming firmware version. Might as well drive the final tmr.alarm() nail into this coffin now and be done with it in a single pass. There is a significant time and labor cost incurred each time you take an existing design through this rework process. |
This is not affected.
Which benefit do you see for supporting local tobj = tmr.create()
tmr.alarm(tobj, 1000, tmr.ALARM_SINGLE, function() print("ping") end) in addition to local tobj = tmr.create()
tobj:alarm(1000, tmr.ALARM_SINGLE, function() print("ping") end) Easier migration of application code? The firmware doesn't offer the former variant for other object types (e.g. sockets). |
Ahh, got it.
No benefit at all, a misunderstanding, sorry. If it's a breaking change anyhow it doesn't matter much if that variant is gone. So, 👍 for removing those functions. |
I think once the admonition is updated and the conflicts in |
I think this makes us good to go; let's see what travis says. |
Fixes #2601.
Make sure all boxes are checked (add x inside the brackets) when you submit your contribution, remove this sentence before doing so.
dev
branch rather than formaster
.docs/en/*
.