Permalink
Browse files

Implement Task.kill

  • Loading branch information...
1 parent cd8c748 commit 80634724eeb716a0d4f2c048142d568500e16aff @tadzik committed Dec 18, 2012
Showing with 24 additions and 0 deletions.
  1. +5 −0 lib/Threads.pm
  2. +19 −0 t/02-kill.t
View
@@ -18,6 +18,11 @@ class Task {
method join {
pir::wait__0P($!task);
}
+
+ method kill {
+ $!task.kill();
+ 1;
+ }
}
sub async(&code) is export {
View
@@ -0,0 +1,19 @@
+use Test;
+plan 1;
+
+use Threads;
+
+my @messages;
+
+my $task = async {
+ @messages.push("Work started");
+ sleep 2;
+ @messages.push("Work finished");
+};
+
+sleep 1;
+$task.kill;
+$task.join;
+
+is +@messages, 1, "The second message never got there";
+exit;

0 comments on commit 8063472

Please sign in to comment.