aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtwiwtg.lisp
diff options
context:
space:
mode:
authorColin Okay <cbeok@protonmail.com>2020-07-10 07:59:27 -0500
committerColin Okay <cbeok@protonmail.com>2020-07-10 07:59:27 -0500
commit09bab9fc37e2de8fe6d8821f1258290f8100c386 (patch)
tree9521b243e8c7ca9f278bcf2edc67add4415572d5 /gtwiwtg.lisp
parent1315832aaeeeb040b276fac4f927be40f1f7e1af (diff)
caveats on experimental generators
Diffstat (limited to 'gtwiwtg.lisp')
-rw-r--r--gtwiwtg.lisp16
1 files changed, 15 insertions, 1 deletions
diff --git a/gtwiwtg.lisp b/gtwiwtg.lisp
index 4e43347..caf5be7 100644
--- a/gtwiwtg.lisp
+++ b/gtwiwtg.lisp
@@ -548,7 +548,14 @@ Caveat:
- The generators produced by NFURCATE! allocate new memory as they
are consumed. This allocation can be O(COUNT * SIZE) in space
complexity, where SIZE is the size of GEN. Hence, use with caution
- on infinite generators.
+ on infinite generators.
+
+ - The SOURCE-GENERATOR will be cleaned up only after all of the
+ returned generators have been consumed. That is if you make some
+ generators using NFURCATE! but do use them, then the
+ SOURCE-GENERATOR may never be cleaned up. I.e. if it is backed by a
+ stream, that stream will not be closed.
+
"
(make-dirty source-generator)
(let ((qs (loop :for _ :below count :collect (make-queue)))
@@ -598,6 +605,13 @@ Caveat:
consume them. This allocation may be O(2 * SIZE) in space
complexity, where SIZE is the size of GEN. Hence, use with caution
on infinite generators.
+
+- The generator GEN will be cleaned up only after both returned
+ generators have been. Hence, you must consume both or you risk
+ leaving some clean up undone. E.g. If GEN is a stream backed
+ generator, the stream will not be closed until both PASSING and
+ FAILING have been consumed.
+
"
(destructuring-bind (gen1 gen2) (nfurcate! 2 gen)
(list (filter! pred gen1)