Skip to content

Instantly share code, notes, and snippets.

@skids
Last active January 26, 2016 05:53
Show Gist options
  • Save skids/fabd0304f40e24db33d0 to your computer and use it in GitHub Desktop.
Save skids/fabd0304f40e24db33d0 to your computer and use it in GitHub Desktop.
Questions on latest round of Supply changes
I'm currently going through S17 to bring it up to date.
The following stuck out as things that may not be intentional behaviors,
so I need to know whether to doc current behavior or file an RT on each:
1) Should two different taps of a a serial supply be run simultaneuosly?
$ perl6 -e 'my $p = Supplier.new; my $s = $p.Supply; $s.serial.say; $s.tap({ sleep 1; "42 {now}".say; }); $s.tap({ sleep 1; "43 {now}".say }); $p.emit(42); sleep 3;'
True
42 Instant:1449454902.847377
43 Instant:1449454903.854135
2) Should two different taps on a non-serial supply be run simultaneously?
$ perl6 -e 'my $p = Supplier.new; my $s = $p.unsanitized-supply; $s.serial.say; $s.tap({ sleep 1; "42 {now}".say; }); $s.tap({ sleep 1; "43 {now}".say }); $p.emit(42); sleep 3;'
False
42 Instant:1449454968.236965
43 Instant:1449454969.243628
3) Should the same tap of a non-serial supply run simultaneously with itself?
$ perl6 -e 'my $p = Supplier.new; my $s = $p.unsanitized-supply; $s.serial.say; $s.tap({ sleep 1; "$_ {now}".say; }); $p.emit(42); $p.emit(43); sleep 3;'
False
42 Instant:1449455041.944167
43 Instant:1449455042.947257
4) Should Supply.list reach IterationEnd when the supply is quit, or throw?
my $r = Supplier.new; my $s = $r.Supply; start { for $s.list { $_.say }; 42.say; CATCH { "OW $_, $!".say } }; sleep 0.5; for 1..4 { $r.emit($_); sleep 0.5 }; $r.quit(X::AdHoc.new(:message<foo>)); sleep 1; '
1
2
3
4
Use of Nil in string context in block at -e:1
OW Unexplained error,
5) Should Supply.wait throw when the supply is quit?
$ perl6 -e 'my $r = Supplier.new; my $s = $r.Supply; start { $s.wait; 42.say; CATCH { "OW $_, $!".say }}; sleep 0.5; for 1..4 { $r.emit($_); sleep 0.5 }; $r.quit(X::AdHoc.new(:message<foo>)); sleep 1;'
Use of Nil in string context in block at -e:1
OW Unexplained error,
6) I'm guessing this one is clearly a bug, but then after that's dealt with, should this just IterationEnd?
$ perl6 -e 'my $r = Supplier.new; my $s = $r.Supply; start { for $s.Channel { $_.say }; 42.say; }; sleep 0.5; for 1..4 { $r.emit($_); sleep 0.5 }; $r.quit(X::AdHoc.new(:message<foo>)); sleep 1;'
1
2
3
4
Method 'quit' not found for invocant of class 'Channel'
in block <unit> at -e:1
7) Behavior of "quit" again, for Supply.Promise:
$ perl6 -e 'my $r = Supplier.new; my $s = $r.Supply; start { my $p = $s.Promise; $p.result.say; 42.say; $p.perl.say; CATCH { "OW $_, $!".say } }; sleep 0.5; for 1..4 { $r.emit($_); sleep 0.5 }; $r.quit(X::AdHoc.new(:message<foo>)); sleep 1;'
Use of Nil in string context in block at -e:1
OW Unexplained error,
$
8) Is Supply.Promise supposed to let the last emitted value escape out to the recipient of the Promise? The Supply owner may not want that and if they do, could hand out Supply.last() instead.
$ perl6 -e 'my $r = Supplier.new; my $s = $r.Supply; start { my $p = $s.Promise; $p.result.say; 42.say; $p.perl.say }; sleep 0.5; for 3..5 { $r.emit($_); sleep 0.5 }; $r.done(); sleep 1;'
5
42
Promise.new(scheduler => ThreadPoolScheduler.new(initial_threads => 0, max_threads => 16, uncaught_handler => Callable), status => PromiseStatus::Kept)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment