Skip to content

Instantly share code, notes, and snippets.

@autarch
Created December 6, 2015 19:29
Show Gist options
  • Select an option

  • Save autarch/fc41bcaf31f05651a2c5 to your computer and use it in GitHub Desktop.

Select an option

Save autarch/fc41bcaf31f05651a2c5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
use v6;
sub MAIN {
my $supply = (1, 2, 3, 4, 5).Supply;
my $sched = ThreadPoolScheduler.new(
:initial_threads(4),
:max_threads(8),
);
$supply.schedule-on($sched);
$supply.tap(
sub ($item) {
say "Tap #1 got $item in thread #{$*THREAD.id}";
}
);
say "Adding next tap";
$supply.tap(
sub ($item) {
say "Tap #2 got $item in thread #{$*THREAD.id}";
},
:done( { say "Tap #2 is done in thread #{$*THREAD.id}" } ),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment