diff options
Diffstat (limited to 'tests/async')
-rw-r--r-- | tests/async/tfuturestream.nim | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/async/tfuturestream.nim b/tests/async/tfuturestream.nim index e3480126f..61b3863ac 100644 --- a/tests/async/tfuturestream.nim +++ b/tests/async/tfuturestream.nim @@ -14,21 +14,39 @@ Finished """ import asyncdispatch -var fs = newFutureStream[string]() +var fs = newFutureStream[int]() proc alpha() {.async.} = for i in 0 .. 5: await sleepAsync(1000) - fs.put($i) + fs.put(i) - fs.complete("Done") + fs.complete() proc beta() {.async.} = while not fs.finished: - echo(await fs.takeAsync()) + let (hasValue, value) = await fs.takeAsync() + if hasValue: + echo(value) echo("Finished") asyncCheck alpha() waitFor beta() +# TODO: Something like this should work eventually. +# proc delta(): FutureStream[string] {.async.} = +# for i in 0 .. 5: +# await sleepAsync(1000) +# result.put($i) + +# return "" + +# proc omega() {.async.} = +# let fut = delta() +# while not fut.finished(): +# echo(await fs.takeAsync()) + +# echo("Finished") + +# waitFor omega() \ No newline at end of file |