Created
December 6, 2015 19:29
-
-
Save autarch/fc41bcaf31f05651a2c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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