mirror of
https://github.com/AmberGraceRblx/luau-promise.git
synced 2025-04-25 08:00:03 +00:00
Allow OnCancel to break out of the current loop
This commit is contained in:
parent
9db73644e6
commit
3a96a1d2a7
1 changed files with 3 additions and 2 deletions
|
@ -715,7 +715,9 @@ do
|
||||||
if connection == nil then -- first is nil when connection is nil
|
if connection == nil then -- first is nil when connection is nil
|
||||||
first = node
|
first = node
|
||||||
connection = Promise._timeEvent:Connect(function()
|
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
|
local current = first
|
||||||
first = current.next
|
first = current.next
|
||||||
|
|
||||||
|
@ -727,7 +729,6 @@ do
|
||||||
end
|
end
|
||||||
|
|
||||||
current.resolve(Promise._getTime() - current.startTime)
|
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
|
||||||
end)
|
end)
|
||||||
else -- first is non-nil
|
else -- first is non-nil
|
||||||
|
|
Loading…
Reference in a new issue