diff options
author | Mathias Stearn <redbeard0531@gmail.com> | 2017-12-08 19:55:04 -0500 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2017-12-09 00:55:04 +0000 |
commit | b87ef6553201c73e24b1b53641cc18abe17d6e9b (patch) | |
tree | a6e5a04418c19ada27b4a108d07532c4cacf3cae /tests/async/tasyncall.nim | |
parent | f70d967d2c313fc92ca864cbe856c55c40947aae (diff) | |
download | Nim-b87ef6553201c73e24b1b53641cc18abe17d6e9b.tar.gz |
Use addCallback rather than callback= in asyncfutures.all() (#6850)
* Use addCallback rather than callback= in asyncfutures.all() Addresses part of #6849 * Stop using do notation for #6849 * Update example style
Diffstat (limited to 'tests/async/tasyncall.nim')
-rw-r--r-- | tests/async/tasyncall.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/async/tasyncall.nim b/tests/async/tasyncall.nim index a3926eabd..775dd0c6f 100644 --- a/tests/async/tasyncall.nim +++ b/tests/async/tasyncall.nim @@ -40,6 +40,16 @@ proc testVarargs(x, y, z: int): seq[int] = result = waitFor all(a, b, c) +proc testWithDupes() = + var + tasks = newSeq[Future[void]](taskCount) + fut = futureWithoutValue() + + for i in 0..<taskCount: + tasks[i] = fut + + waitFor all(tasks) + block: let startTime = cpuTime() @@ -58,6 +68,13 @@ block: doAssert execTime * 1000 < taskCount * sleepDuration block: + let startTime = cpuTime() + testWithDupes() + let execTime = cpuTime() - startTime + + doAssert execTime * 1000 < taskCount * sleepDuration + +block: let startTime = cpuTime() results = testVarargs(1, 2, 3) |