We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hey, you may recall this PR: #94
Turns out that it actually introduced a new issue which can be demonstrated with the following code:
local timer = require 'lib.hump.timer'() local handles = {} local function newTimer(index) local newHandle = timer:after(1, function() print('-> excuting timer #' .. index) -- Whichever timer executes first will cancel all of the other timers. for _, handle in ipairs(handles) do timer:cancel(handle) end end) table.insert(handles, newHandle) end for i = 1, 10 do newTimer(i) end print('Updating timers...') timer:update(1) print('Finished.')
Expected Result (Which one callback actually executes is contingent, of course.)
Updating timers... -> excuting timer #9 Finished.
Actual Result (Again, the order here is contingent)
Updating timers... -> excuting timer #6 -> excuting timer #5 -> excuting timer #2 -> excuting timer #8 -> excuting timer #10 -> excuting timer #1 -> excuting timer #4 -> excuting timer #7 -> excuting timer #3 -> excuting timer #9 Finished.
This issue can be fixed by adding a check like if self.functions[handle] == nil then <continue> end during the primary loop in Timer:update().
if self.functions[handle] == nil then <continue> end
Timer:update()
I didn't send you a PR because there are a few different styles of achieving a "continue" in Lua, and I wasn't sure which you'd prefer.
The text was updated successfully, but these errors were encountered:
0bf301f
Thanks!
Sorry, something went wrong.
No branches or pull requests
Hey, you may recall this PR: #94
Turns out that it actually introduced a new issue which can be demonstrated with the following code:
Expected Result (Which one callback actually executes is contingent, of course.)
Actual Result (Again, the order here is contingent)
This issue can be fixed by adding a check like
if self.functions[handle] == nil then <continue> end
during the primary loop inTimer:update()
.I didn't send you a PR because there are a few different styles of achieving a "continue" in Lua, and I wasn't sure which you'd prefer.
The text was updated successfully, but these errors were encountered: