Merge pull request #5938 from zielmicha/futures

[WIP] Better Future
This commit is contained in:
Dominik Picheta 2017-07-14 20:18:06 +01:00 • committed by GitHub
commit 8b107972c5
6 changed files with 259 additions and 145 deletions

View file

@ -17,5 +17,6 @@ proc asyncRecursionTest*(): Future[int] {.async.} =
inc(i)
when isMainModule:
setGlobalDispatcher(newDispatcher())
var i = waitFor asyncRecursionTest()
echo i

View file

@ -0,0 +1,20 @@
discard """
exitcode: 0
output: '''3
2
1
5
'''
"""
import asyncfutures
let f1: Future[int] = newFuture[int]()
f1.addCallback(proc() = echo 1)
f1.addCallback(proc() = echo 2)
f1.addCallback(proc() = echo 3)
f1.complete(10)
let f2: Future[int] = newFuture[int]()
f2.addCallback(proc() = echo 4)
f2.callback = proc() = echo 5
f2.complete(10)