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
|
completedFutures = 0
|
||||||
|
|
||||||
for i, fut in futs:
|
for i, fut in futs:
|
||||||
fut.callback = proc(f: Future[A]) =
|
proc setCallback(i: int) =
|
||||||
retValues[i] = f.read()
|
fut.callback = proc(f: Future[A]) =
|
||||||
inc(completedFutures)
|
retValues[i] = f.read()
|
||||||
|
inc(completedFutures)
|
||||||
|
|
||||||
if completedFutures == len(futs):
|
if completedFutures == len(retValues):
|
||||||
retFuture.complete(retValues)
|
retFuture.complete(retValues)
|
||||||
|
|
||||||
|
setCallback(i)
|
||||||
|
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue