newruntime: async progress
This commit is contained in:
parent
73c570d1d9
commit
55e8aefbea
3 changed files with 27 additions and 11 deletions
|
|
@ -154,7 +154,7 @@ type
|
||||||
uninit: IntSet # set of uninit'ed vars
|
uninit: IntSet # set of uninit'ed vars
|
||||||
uninitComputed: bool
|
uninitComputed: bool
|
||||||
|
|
||||||
const toDebug = ""
|
const toDebug = "" # "server_continue"
|
||||||
|
|
||||||
template dbg(body) =
|
template dbg(body) =
|
||||||
when toDebug.len > 0:
|
when toDebug.len > 0:
|
||||||
|
|
|
||||||
|
|
@ -144,8 +144,11 @@ proc checkFinished[T](future: Future[T]) =
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
proc call(callbacks: var CallbackList) =
|
proc call(callbacks: var CallbackList) =
|
||||||
|
when not defined(nimV2):
|
||||||
|
# strictly speaking a little code duplication here, but we strive
|
||||||
|
# to minimize regressions and I'm not sure I got the 'nimV2' logic
|
||||||
|
# right:
|
||||||
var current = callbacks
|
var current = callbacks
|
||||||
|
|
||||||
while true:
|
while true:
|
||||||
if not current.function.isNil:
|
if not current.function.isNil:
|
||||||
callSoon(current.function)
|
callSoon(current.function)
|
||||||
|
|
@ -154,6 +157,19 @@ proc call(callbacks: var CallbackList) =
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
current = current.next[]
|
current = current.next[]
|
||||||
|
else:
|
||||||
|
var currentFunc = unown callbacks.function
|
||||||
|
var currentNext = unown callbacks.next
|
||||||
|
|
||||||
|
while true:
|
||||||
|
if not currentFunc.isNil:
|
||||||
|
callSoon(currentFunc)
|
||||||
|
|
||||||
|
if currentNext.isNil:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
currentFunc = currentNext.function
|
||||||
|
currentNext = unown currentNext.next
|
||||||
|
|
||||||
# callback will be called only once, let GC collect them now
|
# callback will be called only once, let GC collect them now
|
||||||
callbacks.next = nil
|
callbacks.next = nil
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ template createCb(retFutureSym, iteratorNameSym,
|
||||||
proc identName {.closure.} =
|
proc identName {.closure.} =
|
||||||
try:
|
try:
|
||||||
if not nameIterVar.finished:
|
if not nameIterVar.finished:
|
||||||
var next = nameIterVar()
|
var next = unown nameIterVar()
|
||||||
# Continue while the yielded future is already finished.
|
# Continue while the yielded future is already finished.
|
||||||
while (not next.isNil) and next.finished:
|
while (not next.isNil) and next.finished:
|
||||||
next = nameIterVar()
|
next = unown nameIterVar()
|
||||||
if nameIterVar.finished:
|
if nameIterVar.finished:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue