diff options
author | Konstantin Molchanov <kmolchanov@machinezone.com> | 2016-05-31 14:56:45 +0400 |
---|---|---|
committer | Konstantin Molchanov <kmolchanov@machinezone.com> | 2016-05-31 14:56:45 +0400 |
commit | 5a007a84fc8350a3a43ddc712c7a59a9ab2dce79 (patch) | |
tree | 33ed1d4de3299ebd87124fc0dfd3957aa4b9af89 /lib | |
parent | fb9fa5f6a385d1861885b0481573e7dc97191d9f (diff) | |
download | Nim-5a007a84fc8350a3a43ddc712c7a59a9ab2dce79.tar.gz |
Stdlib: asyncdispatch: `all` proc: Fix incorect counter value issue.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/asyncdispatch.nim | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index de86cd5ef..53c78d929 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -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 |