WIP implementation of FutureStream.
This commit is contained in:
parent
a20b4c674e
commit
e189004a03
2 changed files with 103 additions and 8 deletions
19
tests/async/tfuturestream.nim
Normal file
19
tests/async/tfuturestream.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import asyncdispatch
|
||||
|
||||
var fs = newFutureStream[string]()
|
||||
|
||||
proc alpha() {.async.} =
|
||||
for i in 0 .. 5:
|
||||
fs.put($i)
|
||||
await sleepAsync(1000)
|
||||
|
||||
fs.complete()
|
||||
|
||||
proc beta() {.async.} =
|
||||
while not fs.finished():
|
||||
echo(await fs.takeAsync())
|
||||
|
||||
echo("Finished")
|
||||
|
||||
asyncCheck alpha()
|
||||
asyncCheck beta()
|
||||
Loading…
Add table
Add a link
Reference in a new issue