Created
June 10, 2014 16:15
-
-
Save anonymous/1606248d28b4f1430e88 to your computer and use it in GitHub Desktop.
This file contains 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
class Foo { | |
has ThreadPoolScheduler $!scheduler = ThreadPoolScheduler.new; | |
has Channel $.c = Channel.new; | |
has Thread $.t; | |
method push ($any) { | |
$!c.send($any); | |
} | |
method BUILD { | |
say "run"; | |
my $stop; | |
$!scheduler = ThreadPoolScheduler.new; | |
$!scheduler.cue( | |
:every(0), | |
:catch{$stop}, | |
{ | |
say "start"; | |
loop { | |
my $msg = $!c.receive; | |
note "Got $msg"; | |
note "Got $msg still"; | |
last if $msg == 3; | |
} | |
say "stop"; | |
}, | |
); | |
say "...ning"; | |
} | |
} | |
my $a = Foo.new; | |
#$a.run; | |
say "Sleep"; | |
$a.push(7); | |
sleep 1; | |
$a.push(3); | |
say "pushed"; | |
sleep 2; | |
say "die"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment