diff options
author | Igor Ribeiro de Assis <igor.assis@gmail.com> | 2021-03-16 21:46:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-16 21:46:22 +0100 |
commit | 9bb0e557497c6d66ef7bdcda765098fd0271726f (patch) | |
tree | 6b606cacbbf53e7a3de3800d58d1718140635e9b /lib/pure/asyncstreams.nim | |
parent | 895a40d1ac305171b8581bed9a951901f5b73328 (diff) | |
download | Nim-9bb0e557497c6d66ef7bdcda765098fd0271726f.tar.gz |
Fix FutureStream memory usage (#17395) [backport:1.2]
Diffstat (limited to 'lib/pure/asyncstreams.nim')
-rw-r--r-- | lib/pure/asyncstreams.nim | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/pure/asyncstreams.nim b/lib/pure/asyncstreams.nim index 7fe86aa05..083c6f0ea 100644 --- a/lib/pure/asyncstreams.nim +++ b/lib/pure/asyncstreams.nim @@ -127,7 +127,11 @@ proc read*[T](future: FutureStream[T]): owned(Future[(bool, T)]) = resFut.complete(res) # If the saved callback isn't nil then let's call it. - if not savedCb.isNil: savedCb() + if not savedCb.isNil: + if fs.queue.len > 0: + savedCb() + else: + future.cb = savedCb if future.queue.len > 0 or future.finished: newCb(future) |