You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error('Failed to execute thread: ' ..debug.traceback(coro, err))
42
-
end
43
-
44
-
ifresumedThreadandcoroutine.status(coro) ~='dead' then
45
-
table.insert(threads, t)
46
-
end
47
-
48
-
returncoroutine.status(coro) ~='dead'
47
+
returnresumeThread(coro)
49
48
end
50
49
51
-
localinNext
52
-
53
50
functionCitizen.Await(promise)
54
-
ifnotcurThreadthen
51
+
localcoro=coroutine.running()
52
+
ifnotcorothen
55
53
error("Current execution context is not in the scheduler, you should use CreateThread / SetTimeout or Event system (AddEventHandler) to be able to Await")
56
54
end
57
55
58
-
-- Remove current thread from the pool (avoid resume from the loop)
59
-
ifcurThreadIndexthen
60
-
table.remove(threads, curThreadIndex)
61
-
end
62
-
63
-
curThreadIndex=nil
64
-
localresumableThread=curThread
65
-
66
-
inNext=true
67
-
localnextResult
68
-
localnextErr
69
-
localresolved
70
-
71
-
promise:next(function (result)
72
-
-- was already resolved? then resolve instantly
73
-
ifinNextthen
74
-
nextResult=result
75
-
resolved=true
76
-
77
-
return
78
-
end
79
-
80
-
-- Reattach thread
81
-
table.insert(threads, resumableThread)
82
-
83
-
curThread=resumableThread
84
-
curThreadIndex=#threads
56
+
-- Indicates if the promise has already been resolved or rejected
57
+
-- This is a hack since the API does not expose its state
0 commit comments