Permalink
Browse files

Use enums instead of classes, masak++

  • Loading branch information...
1 parent 5a8d421 commit 4f35cf4956d080b8d2dac1b2f82225a27d25feee @tadzik committed Dec 13, 2012
Showing with 4 additions and 5 deletions.
  1. +4 −5 lib/Coroutines.pm
View
@@ -2,27 +2,26 @@ module Coroutines;
my @coroutines;
-my class Coro::still_going {};
-my class Coro::done {};
+enum CoroStatus <still_going done>;
sub async(&coroutine) is export {
@coroutines.push($(gather {
&coroutine();
- take Coro::done;
+ take CoroStatus::done;
}));
}
#= must be called from inside a coroutine
sub yield is export {
- take Coro::still_going;
+ take CoroStatus::still_going;
}
#= should be called from mainline code
sub schedule is export {
return unless +@coroutines;
my $r = @coroutines.shift;
my $result = $r.shift;
- if $result ~~ Coro::still_going {
+ if $result ~~ CoroStatus::still_going {
@coroutines.push($r);
}
}

0 comments on commit 4f35cf4

Please sign in to comment.