Implemented a first working version of FutureStreams.
This commit is contained in:
parent
c4d5cc652f
commit
7766fdfec1
3 changed files with 54 additions and 45 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue