From b5daba289c31c267e7ffc09d10a71b2866f4e866 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Thu, 23 May 2024 12:37:47 +0200 Subject: [PATCH] Make BufferIterator also know of its parent --- lib/ParaSeq.rakumod | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/ParaSeq.rakumod b/lib/ParaSeq.rakumod index 02fc583..59230a4 100644 --- a/lib/ParaSeq.rakumod +++ b/lib/ParaSeq.rakumod @@ -22,13 +22,15 @@ my class ParaQueue is repr('ConcBlockingQueue') { } # of the values from the buffer, and then from the iterator my class BufferIterator does Iterator { - has $!buffer; - has $!iterator; + has $!parent; # ParaSeq parent object + has $!buffer; # first buffer to produce from + has $!iterator; # iterator to produce from onwards - method new($buffer, $iterator) { + method new(\parent, \buffer, \iterator) { my $self := nqp::create(self); - nqp::bindattr($self,BufferIterator,'$!buffer', nqp::decont($buffer)); - nqp::bindattr($self,BufferIterator,'$!iterator',$iterator ); + nqp::bindattr($self,BufferIterator,'$!parent', parent ); + nqp::bindattr($self,BufferIterator,'$!buffer', buffer ); + nqp::bindattr($self,BufferIterator,'$!iterator',iterator); $self } @@ -586,7 +588,7 @@ class ParaSeq does Sequence { # one. Otherwise method iterator(ParaSeq:D:) { $!result //= nqp::istype($!buffer,IterationBuffer) - ?? BufferIterator.new($!buffer, $!source) + ?? BufferIterator.new(self, $!buffer, $!source) !! $!source }