/** * Implements IJobManager#suspend(ISchedulingRule, IProgressMonitor) * @param rule * @param monitor */ void suspend(ISchedulingRule rule, IProgressMonitor monitor) { if (JobManager.DEBUG_BEGIN_END) JobManager.debug("Suspend rule: " + rule); //$NON-NLS-1$ //the suspend job will be remembered once the rule is acquired begin(rule, monitor, true); }
@Override public void endRule(ISchedulingRule rule) { implicitJobs.end(rule, false); }
/** (non-Javadoc) * @deprecated this method should not be used * @see org.eclipse.core.runtime.jobs.IJobManager#resume(org.eclipse.core.runtime.jobs.ISchedulingRule) */ public final void resume(ISchedulingRule rule) { implicitJobs.resume(rule); }
private void endThreadJob(ThreadJob threadJob, boolean resume) { Thread currentThread = Thread.currentThread(); //clean up when last rule scope exits threadJobs.remove(currentThread); ISchedulingRule rule = threadJob.getRule(); if (resume && rule != null) suspendedRules.remove(rule); //if this job had a rule, then we are essentially releasing a lock //note it is safe to do this even if the acquire was aborted if (threadJob.acquireRule) { manager.getLockManager().removeLockThread(currentThread, rule); notifyWaitingThreadJobs(); } //if the job was started, we need to notify job manager to end it if (threadJob.isRunning()) manager.endJob(threadJob, Status.OK_STATUS, false); recycle(threadJob); }
/** * Called when a worker thread has finished running a job. At this * point, the worker thread must not own any scheduling rules * @param lastJob The last job to run in this thread */ void endJob(InternalJob lastJob) { final Thread currentThread = Thread.currentThread(); IStatus error; synchronized (this) { ThreadJob threadJob = threadJobs.get(currentThread); if (threadJob == null) { if (lastJob.getRule() != null) notifyWaitingThreadJobs(lastJob); return; } String msg = "Worker thread ended job: " + lastJob + ", but still holds rule: " + threadJob; //$NON-NLS-1$ //$NON-NLS-2$ error = new Status(IStatus.ERROR, JobManager.PI_JOBS, 1, msg, null); //end the thread job endThreadJob(threadJob, false); } try { RuntimeLog.log(error); } catch (RuntimeException e) { //failed to log, so print to console instead System.err.println(error.getMessage()); } }
threadJob = newThreadJob(realJob.getRule()); else { threadJob = newThreadJob(rule); threadJob.acquireRule = true; if (isSuspended(rule)) threadJob.acquireRule = false;
synchronized void removeWaiting(ThreadJob threadJob) { synchronized (((InternalJob) threadJob).jobStateLock) { threadJob.isWaiting = false; notifyWaitingThreadJobs(threadJob); ((InternalJob) threadJob).setWaitQueueStamp(InternalJob.T_NONE); } manager.dequeue(manager.waitingThreadJobs, threadJob); }
synchronized void end(ISchedulingRule rule, boolean resume) { if (JobManager.DEBUG_BEGIN_END) JobManager.debug("End rule: " + rule); //$NON-NLS-1$ ThreadJob threadJob = threadJobs.get(Thread.currentThread()); if (threadJob == null) Assert.isLegal(rule == null, "endRule without matching beginRule: " + rule); //$NON-NLS-1$ else if (threadJob.pop(rule)) { endThreadJob(threadJob, resume); } }
/** (non-Javadoc) * @deprecated this method should not be used * @see org.eclipse.core.runtime.jobs.IJobManager#suspend(org.eclipse.core.runtime.jobs.ISchedulingRule, org.eclipse.core.runtime.IProgressMonitor) */ public final void suspend(ISchedulingRule rule, IProgressMonitor monitor) { Assert.isNotNull(rule); implicitJobs.suspend(rule, monitorFor(monitor)); }
/** * Signals the end of a job. Note that this method can be called under * OutOfMemoryError conditions and thus must be paranoid about allocating objects. */ protected void endJob(InternalJob job, IStatus result) { decrementBusyThreads(); //need to end rule in graph before ending job so that 2 threads //do not become the owners of the same rule in the graph if ((job.getRule() != null) && !(job instanceof ThreadJob)) { //remove any locks this thread may be owning on that rule manager.getLockManager().removeLockCompletely(Thread.currentThread(), job.getRule()); } manager.endJob(job, result, true); //ensure this thread no longer owns any scheduling rules manager.implicitJobs.endJob(job); }
/** * @GuardedBy("this") */ private void endThreadJob(ThreadJob threadJob, boolean resume) { Thread currentThread = Thread.currentThread(); //clean up when last rule scope exits threadJobs.remove(currentThread); ISchedulingRule rule = threadJob.getRule(); if (resume && rule != null) suspendedRules.remove(rule); //if this job had a rule, then we are essentially releasing a lock //note it is safe to do this even if the acquire was aborted if (threadJob.acquireRule) { manager.getLockManager().removeLockThread(currentThread, rule); notifyWaitingThreadJobs(threadJob); } //if the job was started, we need to notify job manager to end it if (threadJob.isRunning()) manager.endJob(threadJob, Status.OK_STATUS, false); recycle(threadJob); }
/** * Called when a worker thread has finished running a job. At this * point, the worker thread must not own any scheduling rules * @param lastJob The last job to run in this thread */ void endJob(InternalJob lastJob) { final Thread currentThread = Thread.currentThread(); IStatus error; synchronized (this) { ThreadJob threadJob = threadJobs.get(currentThread); if (threadJob == null) { if (lastJob.getRule() != null) notifyWaitingThreadJobs(lastJob); return; } String msg = "Worker thread ended job: " + lastJob + ", but still holds rule: " + threadJob; //$NON-NLS-1$ //$NON-NLS-2$ error = new Status(IStatus.ERROR, JobManager.PI_JOBS, 1, msg, null); //end the thread job endThreadJob(threadJob, false); } try { RuntimeLog.log(error); } catch (RuntimeException e) { //failed to log, so print to console instead System.err.println(error.getMessage()); } }
threadJob = newThreadJob(realJob.getRule()); else { threadJob = newThreadJob(rule); threadJob.acquireRule = true; if (isSuspended(rule)) threadJob.acquireRule = false;
synchronized void removeWaiting(ThreadJob threadJob) { synchronized (((InternalJob) threadJob).jobStateLock) { threadJob.isWaiting = false; notifyWaitingThreadJobs(threadJob); ((InternalJob) threadJob).setWaitQueueStamp(InternalJob.T_NONE); } manager.dequeue(manager.waitingThreadJobs, threadJob); }
synchronized void end(ISchedulingRule rule, boolean resume) { if (JobManager.DEBUG_BEGIN_END) JobManager.debug("End rule: " + rule); //$NON-NLS-1$ ThreadJob threadJob = (ThreadJob) threadJobs.get(Thread.currentThread()); if (threadJob == null) Assert.isLegal(rule == null, "endRule without matching beginRule: " + rule); //$NON-NLS-1$ else if (threadJob.pop(rule)) { endThreadJob(threadJob, resume); } }
@Deprecated @Override public final void suspend(ISchedulingRule rule, IProgressMonitor monitor) { Assert.isNotNull(rule); implicitJobs.suspend(rule, monitorFor(monitor)); }
/** * Signals the end of a job. Note that this method can be called under * OutOfMemoryError conditions and thus must be paranoid about allocating objects. */ protected void endJob(InternalJob job, IStatus result) { try { //need to end rule in graph before ending job so that 2 threads //do not become the owners of the same rule in the graph if ((job.getRule() != null) && !(job instanceof ThreadJob)) { //remove any locks this thread may be owning on that rule manager.getLockManager().removeLockCompletely(Thread.currentThread(), job.getRule()); } manager.endJob(job, result, true); //ensure this thread no longer owns any scheduling rules manager.implicitJobs.endJob(job); } finally { decrementBusyThreads(); } }
/** * @GuardedBy("this") */ private void endThreadJob(ThreadJob threadJob, boolean resume) { Thread currentThread = Thread.currentThread(); //clean up when last rule scope exits threadJobs.remove(currentThread); ISchedulingRule rule = threadJob.getRule(); if (resume && rule != null) suspendedRules.remove(rule); //if this job had a rule, then we are essentially releasing a lock //note it is safe to do this even if the acquire was aborted if (threadJob.acquireRule) { manager.getLockManager().removeLockThread(currentThread, rule); notifyWaitingThreadJobs(threadJob); } //if the job was started, we need to notify job manager to end it if (threadJob.isRunning()) manager.endJob(threadJob, Status.OK_STATUS, false); recycle(threadJob); }
/** * Called when a worker thread has finished running a job. At this * point, the worker thread must not own any scheduling rules * @param lastJob The last job to run in this thread */ void endJob(InternalJob lastJob) { final Thread currentThread = Thread.currentThread(); IStatus error; synchronized (this) { ThreadJob threadJob = (ThreadJob) threadJobs.get(currentThread); if (threadJob == null) { if (lastJob.getRule() != null) notifyWaitingThreadJobs(); return; } String msg = "Worker thread ended job: " + lastJob + ", but still holds rule: " + threadJob; //$NON-NLS-1$ //$NON-NLS-2$ error = new Status(IStatus.ERROR, JobManager.PI_JOBS, 1, msg, null); //end the thread job endThreadJob(threadJob, false); } try { RuntimeLog.log(error); } catch (RuntimeException e) { //failed to log, so print to console instead System.err.println(error.getMessage()); } }
threadJob = newThreadJob(realJob.getRule()); else { threadJob = newThreadJob(rule); threadJob.acquireRule = true; if (isSuspended(rule)) threadJob.acquireRule = false;