summary refs log tree commit diff stats
path: root/tests/async/tfuturestream.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/async/tfuturestream.nim')
-rw-r--r--tests/async/tfuturestream.nim19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/async/tfuturestream.nim b/tests/async/tfuturestream.nim
new file mode 100644
index 000000000..ed5ac5785
--- /dev/null
+++ b/tests/async/tfuturestream.nim
@@ -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()
\ No newline at end of file