Allow OnCancel to break out of the current loop

This commit is contained in:
Niles 2020-08-22 03:49:59 -05:00 committed by GitHub
parent 9db73644e6
commit 3a96a1d2a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -715,7 +715,9 @@ do
if connection == nil then -- first is nil when connection is nil
first = node
connection = Promise._timeEvent:Connect(function()
while first.endTime <= Promise._getTime() do
local threadStart = Promise._getTime()
while first ~= nil and first.endTime < threadStart do
local current = first
first = current.next
@ -727,7 +729,6 @@ do
end
current.resolve(Promise._getTime() - current.startTime)
if current.next == nil then return end -- kill this thread if there was no `first` before `resolve`
end
end)
else -- first is non-nil