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
This commit is contained in:
parent
f70d967d2c
commit
b87ef65532
3 changed files with 22 additions and 4 deletions
|
|
@ -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()
|
||||
|
|
@ -57,6 +67,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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue