BackgroundJob.st
changeset 2711 4e821abc0c2e
parent 2706 99b71585e8d0
child 2736 5f916a59f5e6
--- a/BackgroundJob.st	Tue Jan 31 18:19:11 2012 +0100
+++ b/BackgroundJob.st	Thu Feb 09 23:58:36 2012 +0100
@@ -253,6 +253,29 @@
 
 !BackgroundJob methodsFor:'start & stop'!
 
+abort
+    "Abort the job, if it is running. Similar to #stop, but raises 
+     abort operation request so the job has a chance to terminate
+     gracefully"
+
+    | t |
+
+    (t := thread) isNil ifTrue:[^self].
+    t interruptWith:[
+        NoHandlerError handle:[:ex |
+            ex parameter signal == AbortOperationRequest ifTrue:[
+                ex return.
+            ].
+            ex reject.
+        ] do:[
+            AbortOperationRequest raise.
+        ].
+    ].
+    self stop
+
+    "Created: / 09-02-2012 / 19:34:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 restart
 
     running ifTrue:[
@@ -309,11 +332,11 @@
 !BackgroundJob class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/BackgroundJob.st,v 1.10 2012-01-20 17:26:27 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/BackgroundJob.st,v 1.11 2012-02-09 22:58:36 vrany Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/BackgroundJob.st,v 1.10 2012-01-20 17:26:27 vrany Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/BackgroundJob.st,v 1.11 2012-02-09 22:58:36 vrany Exp $'
 !
 
 version_SVN