summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@gmail.com>2016-11-21 23:44:38 +0100
committerDominik Picheta <dominikpicheta@gmail.com>2016-11-21 23:44:38 +0100
commitc538e1ae084ed7a1888c37b7c267449f166b9c11 (patch)
tree1d368127615fcfd80de657a0b167169c8117495e
parente6f6323e770d326e633c5f1d7e5205d7cb2c4ca3 (diff)
downloadNim-c538e1ae084ed7a1888c37b7c267449f166b9c11.tar.gz
Fixes asyncdispatch.all completing its res future more than once.
-rw-r--r--lib/pure/includes/asyncfutures.nim31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/pure/includes/asyncfutures.nim b/lib/pure/includes/asyncfutures.nim
index dfcfa37a0..029c5f157 100644
--- a/lib/pure/includes/asyncfutures.nim
+++ b/lib/pure/includes/asyncfutures.nim
@@ -263,13 +263,13 @@ proc all*[T](futs: varargs[Future[T]]): auto =
 
     for fut in futs:
       fut.callback = proc(f: Future[T]) =
-        if f.failed:
-          retFuture.fail(f.error)
-        elif not retFuture.finished:
-          inc(completedFutures)
-
-          if completedFutures == totalFutures:
-            retFuture.complete()
+        inc(completedFutures)
+        if not retFuture.finished:
+          if f.failed:
+            retFuture.fail(f.error)
+          else:
+            if completedFutures == totalFutures:
+              retFuture.complete()
 
     if totalFutures == 0:
       retFuture.complete()
@@ -285,14 +285,15 @@ proc all*[T](futs: varargs[Future[T]]): auto =
     for i, fut in futs:
       proc setCallback(i: int) =
         fut.callback = proc(f: Future[T]) =
-          if f.failed:
-            retFuture.fail(f.error)
-          elif not retFuture.finished:
-            retValues[i] = f.read()
-            inc(completedFutures)
-
-            if completedFutures == len(retValues):
-              retFuture.complete(retValues)
+          inc(completedFutures)
+          if not retFuture.finished:
+            if f.failed:
+              retFuture.fail(f.error)
+            else:
+              retValues[i] = f.read()
+
+              if completedFutures == len(retValues):
+                retFuture.complete(retValues)
 
       setCallback(i)
 
.com> 2015-09-15 19:13:07 +0100 Updated CHANGELOG' href='/danisanti/profani-tty/commit/CHANGELOG?id=a3dccce2fa859b3030d740b609fa9e9466601cc7'>a3dccce2 ^
06882c01 ^

0269129d ^
a7de5933 ^


0bf9d324 ^
a7de5933 ^
0bf9d324 ^




a7de5933 ^
0bf9d324 ^





cd084c7e ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43