Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 122986
Collapse All | Expand All

(-)src/org/eclipse/core/internal/jobs/Worker.java (-2 / +2 lines)
Lines 66-77 Link Here
66
				} catch (Error e) {
66
				} catch (Error e) {
67
					result = handleException(currentJob, e);
67
					result = handleException(currentJob, e);
68
				} finally {
68
				} finally {
69
					//clear interrupted state for this thread
70
					Thread.interrupted();
71
					//result must not be null
69
					//result must not be null
72
					if (result == null)
70
					if (result == null)
73
						result = handleException(currentJob, new NullPointerException());
71
						result = handleException(currentJob, new NullPointerException());
74
					pool.endJob(currentJob, result);
72
					pool.endJob(currentJob, result);
73
					//clear interrupted state for this thread
74
					Thread.interrupted();
75
					if ((result.getSeverity() & (IStatus.ERROR | IStatus.WARNING)) != 0)
75
					if ((result.getSeverity() & (IStatus.ERROR | IStatus.WARNING)) != 0)
76
						RuntimeLog.log(result);
76
						RuntimeLog.log(result);
77
					currentJob = null;
77
					currentJob = null;
(-)src/org/eclipse/core/internal/jobs/JobManager.java (+3 lines)
Lines 231-236 Link Here
231
				case Job.RUNNING :
231
				case Job.RUNNING :
232
					//cannot cancel a job that has already started (as opposed to ABOUT_TO_RUN)
232
					//cannot cancel a job that has already started (as opposed to ABOUT_TO_RUN)
233
					if (job.internalGetState() == Job.RUNNING) {
233
					if (job.internalGetState() == Job.RUNNING) {
234
						Thread t=job.getThread();
235
						if(t!=null)
236
							t.interrupt();
234
						monitor = job.getProgressMonitor();
237
						monitor = job.getProgressMonitor();
235
						break;
238
						break;
236
					}
239
					}
(-)src/org/eclipse/core/internal/jobs/InternalJob.java (+16 lines)
Lines 42-47 Link Here
42
	private static final int M_STATE = 0xFF;
42
	private static final int M_STATE = 0xFF;
43
	private static final int M_SYSTEM = 0x0100;
43
	private static final int M_SYSTEM = 0x0100;
44
	private static final int M_USER = 0x0200;
44
	private static final int M_USER = 0x0200;
45
	private static final int M_INTERRUPT = 0x0400;
45
46
46
	protected static final JobManager manager = JobManager.getInstance();
47
	protected static final JobManager manager = JobManager.getInstance();
47
	private static int nextJobNumber = 0;
48
	private static int nextJobNumber = 0;
Lines 302-307 Link Here
302
		return (flags & M_USER) != 0;
303
		return (flags & M_USER) != 0;
303
	}
304
	}
304
305
306
	/* (non-javadoc)
307
	 * @see Job.isUser()
308
	 */
309
	protected boolean isInterruptOnCancel() {
310
		return (flags & M_INTERRUPT) != 0;
311
	}
312
305
	/* (non-Javadoc)
313
	/* (non-Javadoc)
306
	 * @see Job#join()
314
	 * @see Job#join()
307
	 */
315
	 */
Lines 490-495 Link Here
490
		flags = value ? flags | M_USER : flags & ~M_USER;
498
		flags = value ? flags | M_USER : flags & ~M_USER;
491
	}
499
	}
492
500
501
	/* (non-javadoc)
502
	 * @see Job.setUser
503
	 */
504
	protected void setInterruptOnCancel(boolean value) {
505
		if (getState() != Job.NONE)
506
			throw new IllegalStateException();
507
		flags = value ? flags | M_INTERRUPT : flags & ~M_INTERRUPT;
508
	}
493
	/* (Non-javadoc)
509
	/* (Non-javadoc)
494
	 * @see Job#shouldSchedule
510
	 * @see Job#shouldSchedule
495
	 */
511
	 */
(-)src/org/eclipse/core/runtime/jobs/Job.java (+23 lines)
Lines 355-360 Link Here
355
	}
355
	}
356
356
357
	/**
357
	/**
358
	 * Returns whether {@link #cancel()} will call {@link Thread#interrupt()}.
359
	 * The default value is <code>false</code>.
360
	 * 
361
	 * @return <code>true</code> if this job gets interrupted on cancel, and
362
	 * <code>false</code> otherwise.
363
	 * @see #setInterruptOnCancel(boolean)
364
	 */
365
	public final boolean isInterruptOnCancel() {
366
		return super.isInterruptOnCancel();
367
	}
368
369
	/**
358
	 * Waits until this job is finished.  This method will block the calling thread until the 
370
	 * Waits until this job is finished.  This method will block the calling thread until the 
359
	 * job has finished executing, or until this thread has been interrupted.  If the job 
371
	 * job has finished executing, or until this thread has been interrupted.  If the job 
360
	 * has not been scheduled, this method returns immediately.
372
	 * has not been scheduled, this method returns immediately.
Lines 565-570 Link Here
565
	public final void setUser(boolean value) {
577
	public final void setUser(boolean value) {
566
		super.setUser(value);
578
		super.setUser(value);
567
	}
579
	}
580
	/**
581
	 * Sets whether {@link #cancel()} will call {@link Thread#interrupt()}.
582
	 * The default value is <code>false</code>.
583
	 * 
584
	 * @param value <code>true</code> if this job gets interrupted on cancel, and
585
	 * <code>false</code> otherwise.
586
	 * @see #isInterruptOnCancel()
587
	 */
588
	public final void setInterruptOnCancel(boolean value) {
589
		super.setInterruptOnCancel(value);
590
	}
568
591
569
	/**
592
	/**
570
	 * Sets the thread that this job is currently running in, or <code>null</code>
593
	 * Sets the thread that this job is currently running in, or <code>null</code>

Return to bug 122986