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
|
||||
uninitComputed: bool
|
||||
|
||||
const toDebug = ""
|
||||
const toDebug = "" # "server_continue"
|
||||
|
||||
template dbg(body) =
|
||||
when toDebug.len > 0:
|
||||
|
|
|
|||
|
|
@ -144,16 +144,32 @@ proc checkFinished[T](future: Future[T]) =
|
|||
raise err
|
||||
|
||||
proc call(callbacks: var CallbackList) =
|
||||
var current = callbacks
|
||||
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
|
||||
while true:
|
||||
if not current.function.isNil:
|
||||
callSoon(current.function)
|
||||
|
||||
while true:
|
||||
if not current.function.isNil:
|
||||
callSoon(current.function)
|
||||
if current.next.isNil:
|
||||
break
|
||||
else:
|
||||
current = current.next[]
|
||||
else:
|
||||
var currentFunc = unown callbacks.function
|
||||
var currentNext = unown callbacks.next
|
||||
|
||||
if current.next.isNil:
|
||||
break
|
||||
else:
|
||||
current = current.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
|
||||
callbacks.next = nil
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ template createCb(retFutureSym, iteratorNameSym,
|
|||
proc identName {.closure.} =
|
||||
try:
|
||||
if not nameIterVar.finished:
|
||||
var next = nameIterVar()
|
||||
var next = unown nameIterVar()
|
||||
# Continue while the yielded future is already finished.
|
||||
while (not next.isNil) and next.finished:
|
||||
next = nameIterVar()
|
||||
next = unown nameIterVar()
|
||||
if nameIterVar.finished:
|
||||
break
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue