Stdlib: asyncdispatch: all proc: Fix incorect counter value issue.
This commit is contained in:
parent
fb9fa5f6a3
commit
5a007a84fc
1 changed files with 8 additions and 5 deletions
|
|
@ -368,12 +368,15 @@ proc all*[A](futs: openarray[Future[A]]): Future[seq[A]] =
|
|||
completedFutures = 0
|
||||
|
||||
for i, fut in futs:
|
||||
fut.callback = proc(f: Future[A]) =
|
||||
retValues[i] = f.read()
|
||||
inc(completedFutures)
|
||||
proc setCallback(i: int) =
|
||||
fut.callback = proc(f: Future[A]) =
|
||||
retValues[i] = f.read()
|
||||
inc(completedFutures)
|
||||
|
||||
if completedFutures == len(futs):
|
||||
retFuture.complete(retValues)
|
||||
if completedFutures == len(retValues):
|
||||
retFuture.complete(retValues)
|
||||
|
||||
setCallback(i)
|
||||
|
||||
return retFuture
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue