On Fri, Oct 15, 2010 at 01:42:06PM +0200, Leon Timmermans wrote: > On Wed, Oct 13, 2010 at 1:20 AM, Tim Bunce <[email protected]> wrote: > > I've not used them, but Ruby 1.9 Fibers (continuations) and the > > EventMachine Reactor pattern seem interesting. > > Continuations and fibers are incredibly useful and should be easy to > implement on parrot/rakudo
Forget Parrot, fibers can be implemented in pure Perl 6.
module Fibers;
my @runq;
sub spawn(&entry) is export {
push @runq, $( gather entry() );
}
sub yield() is export {
take True;
}
sub scheduler() is export {
while @runq {
my $task = shift @runq;
if $task {
$task.shift;
push @runq, $task;
}
}
}
-sorear
signature.asc
Description: Digital signature
