-
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
Feature request: dynamic software timers #1416
Comments
@djphoenix Similar ideas were discussed in #709 but there was never a conclusion on how to continue. Personally, I clearly favour an object-oriented solution like yours. Though with the current API in mind, how about the following approach for backwards compatiblity. As you sketched above, Much of the existing C code for the functions can be re-used / shared if they are augmented to accept a local mytimer = tmr.create()
-- oo calling
mytimer:register(5000, tmr.ALARM_SINGLE, function (t) print("expired"); t:unregister() end)
mytimer:start()
-- with self parameter
tmr.register(mytimer, 5000, tmr.ALARM_SINGLE, function (t) print("expired"); tmr.unregister(t) end)
tmr.start(mytimer)
-- still using an old timer
tmr.register(1, 5000, tmr.ALARM_SINGLE, function (t) print("expired"); tmr.unregister(t) end)
tmr.start(1) Does this sound meaningful? |
Yep, this is good compromise. Let's try it in real world. |
👍 for backwards compatibility. However, I'd like to see the old style functions tagged with a deprecation note both in code and the docs. That'll allow us to remove them maybe half a year later. |
Missing feature
Now we have 7 (0-6) timer control functions. When we need more, we stuck in refactoring.
API proposal
Implementation proposal
I have finished it in my local repo (on top of
ETSTimer
of course), if there is no rejections of idea, I'll cleanup code, write docs and make PR.The text was updated successfully, but these errors were encountered: