From 09bab9fc37e2de8fe6d8821f1258290f8100c386 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 10 Jul 2020 07:59:27 -0500 Subject: caveats on experimental generators --- gtwiwtg.lisp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3