Implemented a first working version of FutureStreams.

This commit is contained in:
Dominik Picheta 2017-02-10 00:06:18 +01:00
commit 7766fdfec1
3 changed files with 54 additions and 45 deletions

View file

@ -4,16 +4,17 @@ var fs = newFutureStream[string]()
proc alpha() {.async.} =
for i in 0 .. 5:
fs.put($i)
await sleepAsync(1000)
fs.put($i)
fs.complete()
fs.complete("Done")
proc beta() {.async.} =
while not fs.finished():
while not fs.finished:
echo(await fs.takeAsync())
echo("Finished")
asyncCheck alpha()
asyncCheck beta()
waitFor beta()