Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 52904 Details for
Bug 122986
[jobs] Job should allow cancel() to notify someone a cancel has been requested
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to optionally call Thread.interrupt() on Job.cancel()
job-interrupt-patch.txt (text/plain), 4.85 KB, created by
Michael Scharf
on 2006-10-28 01:44:47 EDT
(
hide
)
Description:
Patch to optionally call Thread.interrupt() on Job.cancel()
Filename:
MIME Type:
Creator:
Michael Scharf
Created:
2006-10-28 01:44:47 EDT
Size:
4.85 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.jobs >Index: src/org/eclipse/core/internal/jobs/Worker.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/Worker.java,v >retrieving revision 1.2 >diff -u -r1.2 Worker.java >--- src/org/eclipse/core/internal/jobs/Worker.java 11 Jan 2006 20:17:32 -0000 1.2 >+++ src/org/eclipse/core/internal/jobs/Worker.java 28 Oct 2006 05:42:00 -0000 >@@ -66,12 +66,12 @@ > } catch (Error e) { > result = handleException(currentJob, e); > } finally { >- //clear interrupted state for this thread >- Thread.interrupted(); > //result must not be null > if (result == null) > result = handleException(currentJob, new NullPointerException()); > pool.endJob(currentJob, result); >+ //clear interrupted state for this thread >+ Thread.interrupted(); > if ((result.getSeverity() & (IStatus.ERROR | IStatus.WARNING)) != 0) > RuntimeLog.log(result); > currentJob = null; >Index: src/org/eclipse/core/internal/jobs/JobManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java,v >retrieving revision 1.17 >diff -u -r1.17 JobManager.java >--- src/org/eclipse/core/internal/jobs/JobManager.java 25 Oct 2006 21:39:39 -0000 1.17 >+++ src/org/eclipse/core/internal/jobs/JobManager.java 28 Oct 2006 05:42:00 -0000 >@@ -231,6 +231,9 @@ > case Job.RUNNING : > //cannot cancel a job that has already started (as opposed to ABOUT_TO_RUN) > if (job.internalGetState() == Job.RUNNING) { >+ Thread t=job.getThread(); >+ if(t!=null) >+ t.interrupt(); > monitor = job.getProgressMonitor(); > break; > } >Index: src/org/eclipse/core/internal/jobs/InternalJob.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/InternalJob.java,v >retrieving revision 1.5 >diff -u -r1.5 InternalJob.java >--- src/org/eclipse/core/internal/jobs/InternalJob.java 25 Oct 2006 21:39:38 -0000 1.5 >+++ src/org/eclipse/core/internal/jobs/InternalJob.java 28 Oct 2006 05:41:57 -0000 >@@ -42,6 +42,7 @@ > private static final int M_STATE = 0xFF; > private static final int M_SYSTEM = 0x0100; > private static final int M_USER = 0x0200; >+ private static final int M_INTERRUPT = 0x0400; > > protected static final JobManager manager = JobManager.getInstance(); > private static int nextJobNumber = 0; >@@ -302,6 +303,13 @@ > return (flags & M_USER) != 0; > } > >+ /* (non-javadoc) >+ * @see Job.isUser() >+ */ >+ protected boolean isInterruptOnCancel() { >+ return (flags & M_INTERRUPT) != 0; >+ } >+ > /* (non-Javadoc) > * @see Job#join() > */ >@@ -490,6 +498,14 @@ > flags = value ? flags | M_USER : flags & ~M_USER; > } > >+ /* (non-javadoc) >+ * @see Job.setUser >+ */ >+ protected void setInterruptOnCancel(boolean value) { >+ if (getState() != Job.NONE) >+ throw new IllegalStateException(); >+ flags = value ? flags | M_INTERRUPT : flags & ~M_INTERRUPT; >+ } > /* (Non-javadoc) > * @see Job#shouldSchedule > */ >Index: src/org/eclipse/core/runtime/jobs/Job.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.jobs/src/org/eclipse/core/runtime/jobs/Job.java,v >retrieving revision 1.6 >diff -u -r1.6 Job.java >--- src/org/eclipse/core/runtime/jobs/Job.java 25 Oct 2006 21:39:39 -0000 1.6 >+++ src/org/eclipse/core/runtime/jobs/Job.java 28 Oct 2006 05:42:02 -0000 >@@ -355,6 +355,18 @@ > } > > /** >+ * Returns whether {@link #cancel()} will call {@link Thread#interrupt()}. >+ * The default value is <code>false</code>. >+ * >+ * @return <code>true</code> if this job gets interrupted on cancel, and >+ * <code>false</code> otherwise. >+ * @see #setInterruptOnCancel(boolean) >+ */ >+ public final boolean isInterruptOnCancel() { >+ return super.isInterruptOnCancel(); >+ } >+ >+ /** > * Waits until this job is finished. This method will block the calling thread until the > * job has finished executing, or until this thread has been interrupted. If the job > * has not been scheduled, this method returns immediately. >@@ -565,6 +577,17 @@ > public final void setUser(boolean value) { > super.setUser(value); > } >+ /** >+ * Sets whether {@link #cancel()} will call {@link Thread#interrupt()}. >+ * The default value is <code>false</code>. >+ * >+ * @param value <code>true</code> if this job gets interrupted on cancel, and >+ * <code>false</code> otherwise. >+ * @see #isInterruptOnCancel() >+ */ >+ public final void setInterruptOnCancel(boolean value) { >+ super.setInterruptOnCancel(value); >+ } > > /** > * Sets the thread that this job is currently running in, or <code>null</code>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 122986
: 52904