Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix problem with multiple .tap on SupplyOperations
Spotted and suggested by retupmoca++ .  Basically, a new internal tap was
being created for each tap on the outside: now only the first outside tap
creates an internal tap.
  • Loading branch information
lizmat committed Jul 10, 2014
1 parent 4cad54f commit 9a1c529
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/core/SupplyOperations.pm
Expand Up @@ -124,14 +124,14 @@ my class SupplyOperations is repr('Uninstantiable') {
method flat(Supply $source) {
my class FlatSupply does Supply does PrivatePublishing {
has $!source;
has $!source-tap;

submethod BUILD(:$!source) { }

method live { $source.live }
method tap(|c) {
my $source_tap;
my $tap = self.Supply::tap(|c, closing => {$source_tap.close});
$source_tap = $!source.tap( -> \val {
my $tap = self.Supply::tap(|c, closing => {$!source-tap.close});
$!source-tap //= $!source.tap( -> \val {
self!more(val.flat)
},
done => { self!done(); },
Expand All @@ -145,15 +145,15 @@ my class SupplyOperations is repr('Uninstantiable') {
method grep(Supply $source, Mu $test) {
my class GrepSupply does Supply does PrivatePublishing {
has $!source;
has $!source-tap;
has Mu $!test;

submethod BUILD(:$!source, :$!test) { }

method live { $source.live }
method tap(|c) {
my $source_tap;
my $tap = self.Supply::tap(|c, closing => {$source_tap.close});
$source_tap = $!source.tap( $!test.DEFINITE
my $tap = self.Supply::tap(|c, closing => {$!source-tap.close});
$!source-tap //= $!source.tap( $!test.DEFINITE
?? $!test ~~ Callable
?? $!test ~~ Regex
?? -> \val { self!more(val) if val.match($!test) }
Expand All @@ -172,15 +172,15 @@ my class SupplyOperations is repr('Uninstantiable') {
method map(Supply $source, &mapper) {
my class MapSupply does Supply does PrivatePublishing {
has $!source;
has $!source-tap;
has &!mapper;

submethod BUILD(:$!source, :&!mapper) { }

method live { $source.live }
method tap(|c) {
my $source_tap;
my $tap = self.Supply::tap(|c, closing => {$source_tap.close});
$source_tap = $!source.tap( -> \val {
my $tap = self.Supply::tap(|c, closing => {$!source-tap.close});
$!source-tap //= $!source.tap( -> \val {
self!more(&!mapper(val))
},
done => { self!done(); },
Expand All @@ -194,15 +194,15 @@ my class SupplyOperations is repr('Uninstantiable') {
method schedule_on(Supply $source, Scheduler $scheduler) {
my class ScheduleSupply does Supply does PrivatePublishing {
has $!source;
has $!source-tap;
has $!scheduler;

submethod BUILD(:$!source, :$!scheduler) { }

method live { $source.live }
method tap(|c) {
my $source_tap;
my $tap = self.Supply::tap(|c, closing => {$source_tap.close});
$source_tap = $!source.tap( -> \val {
my $tap = self.Supply::tap(|c, closing => {$!source-tap.close});
$!source-tap //= $!source.tap( -> \val {
$!scheduler.cue: { self!more(val) }
},
done => { $!scheduler.cue: { self!done(); } },
Expand Down Expand Up @@ -246,6 +246,7 @@ my class SupplyOperations is repr('Uninstantiable') {

my class StableSupply does Supply does PrivatePublishing {
has $!source;
has $!source-tap;
has $!time;
has $!scheduler;
has $!lock;
Expand All @@ -257,9 +258,8 @@ my class SupplyOperations is repr('Uninstantiable') {

method live { $source.live }
method tap(|c) {
my $source_tap;
my $tap = self.Supply::tap(|c, closing => {$source_tap.close});
$source_tap = $!source.tap(
my $tap = self.Supply::tap(|c, closing => {$!source-tap.close});
$!source-tap //= $!source.tap(
-> \val {
$!lock.protect({
if $!last_cancellation {
Expand Down Expand Up @@ -289,16 +289,16 @@ my class SupplyOperations is repr('Uninstantiable') {

my class DelaySupply does Supply does PrivatePublishing {
has $!source;
has $!source-tap;
has $!time;
has $!scheduler;

submethod BUILD(:$!source, :$!time, :$!scheduler) { }

method live { $source.live }
method tap(|c) {
my $source_tap;
my $tap = self.Supply::tap(|c, closing => {$source_tap.close});
$source_tap = $!source.tap(
my $tap = self.Supply::tap(|c, closing => {$!source-tap.close});
$!source-tap //= $!source.tap(
-> \val {
$!scheduler.cue( { self!more(val) }, :in($time) );
},
Expand All @@ -317,6 +317,7 @@ my class SupplyOperations is repr('Uninstantiable') {
method migrate(Supply $source) {
my class MigrateSupply does Supply does PrivatePublishing {
has $!source;
has $!source-tap;
has $!current;
has $!lock;

Expand All @@ -326,9 +327,8 @@ my class SupplyOperations is repr('Uninstantiable') {

method live { $source.live }
method tap(|c) {
my $source_tap;
my $tap = self.Supply::tap(|c, closing => {$source_tap.close});
$source_tap = $!source.tap(
my $tap = self.Supply::tap(|c, closing => {$!source-tap.close});
$!source-tap //= $!source.tap(
-> \inner_supply {
X::Supply::Migrate::Needs.new.throw
unless inner_supply ~~ Supply;
Expand All @@ -350,6 +350,7 @@ my class SupplyOperations is repr('Uninstantiable') {
method classify(Supply $source, &mapper, :$multi ) {
my class ClassifySupply does Supply does PrivatePublishing {
has $!source;
has $!source-tap;
has %!mapping;

submethod BUILD(:$!source) { }
Expand All @@ -363,9 +364,8 @@ my class SupplyOperations is repr('Uninstantiable') {

method live { $source.live }
method tap(|c) {
my $source_tap;
my $tap = self.Supply::tap(|c, closing => {$source_tap.close});
$source_tap = $!source.tap( $multi
my $tap = self.Supply::tap(|c, closing => {$!source-tap.close});
$!source-tap //= $!source.tap( $multi
?? -> \val {
for @(mapper(val)) -> $key {
self.find_supply($key).more(val);
Expand Down

0 comments on commit 9a1c529

Please sign in to comment.