Skip to content

Commit

Permalink
Add Supply.rotor(:partial) and deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Apr 25, 2015
1 parent 5aee9b4 commit 0c197cd
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/core/Supply.pm
Original file line number Diff line number Diff line change
Expand Up @@ -342,19 +342,29 @@ my role Supply {
}

proto method rotor(|) {*}
multi method rotor(Supply:D $self: Pair $teeth-gap) { self.rotor($teeth-gap.key, -$teeth-gap.value) }
multi method rotor(Supply:D $self: $elems? is copy, $overlap? is copy ) {

$elems //= 2;
$overlap //= 1;
return $self if $elems == 1 and $overlap == 0; # nothing to do
multi method rotor(Supply:D $self: Pair $teeth-gap, :$partial) {
self.rotor($teeth-gap.key, -$teeth-gap.value, :$partial, :nodepr);
}
multi method rotor(
Supply:D $self:
$elems? is copy,
$gap? is copy,
:$partial,
:$nodepr,
) {
DEPRECATED('.rotor( $elems => -$gap )',|<2015.04 2015.09>)
if $elems.defined && !$nodepr;

$elems //= 2;
$gap //= 1;
return $self if $elems == 1 and $gap == 0; # nothing to do

on -> $res {
$self => do {
my @batched;
sub flush {
$res.emit( [@batched] );
@batched.splice( 0, +@batched - $overlap );
@batched.splice( 0, +@batched - $gap );
}

{
Expand All @@ -363,7 +373,7 @@ my role Supply {
flush if @batched.elems == $elems;
},
done => {
flush if @batched;
flush if @batched and $partial;
$res.done;
}
}
Expand Down

0 comments on commit 0c197cd

Please sign in to comment.