Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement Task.kill

  • Loading branch information...
commit 80634724eeb716a0d4f2c048142d568500e16aff 1 parent cd8c748
@tadzik authored
Showing with 24 additions and 0 deletions.
  1. +5 −0 lib/Threads.pm
  2. +19 −0 t/02-kill.t
View
5 lib/Threads.pm
@@ -18,6 +18,11 @@ class Task {
method join {
pir::wait__0P($!task);
}
+
+ method kill {
+ $!task.kill();
+ 1;
+ }
}
sub async(&code) is export {
View
19 t/02-kill.t
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.