Permalink
Browse files

Make async() code more compact

  • Loading branch information...
1 parent 66b6c19 commit cd8c7482919304829a2bdf476c2360954153e40d @tadzik committed Dec 18, 2012
Showing with 3 additions and 5 deletions.
  1. +3 −5 lib/Threads.pm
View
@@ -11,6 +11,8 @@ class Task {
my Mu $task := pir::new__PSP('Task', $do);
nqp::bindattr(self, Task, '$!task', $task);
pir::schedule__0P($task);
+
+ return self; # allow chaining
}
method join {
@@ -23,9 +25,5 @@ sub async(&code) is export {
&code()
};
- my $t = Task.new(code => $wrapper);
-
- $t.schedule;
-
- return $t;
+ return Task.new(code => $wrapper).schedule
}

0 comments on commit cd8c748

Please sign in to comment.