Skip to content

Commit

Permalink
Make BufferIterator also know of its parent
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed May 23, 2024
1 parent ababd02 commit b5daba2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/ParaSeq.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit b5daba2

Please sign in to comment.