/** * Returns the estimated time in milliseconds before the next job is scheduled * to wake up. The result may be negative. Returns InternalJob.T_INFINITE if * there are no sleeping or waiting jobs. */ protected long sleepHint() { synchronized (lock) { //wait forever if job manager is suspended if (suspended) return InternalJob.T_INFINITE; if (!waiting.isEmpty()) return 0L; //return the anticipated time that the next sleeping job will wake InternalJob next = sleeping.peek(); if (next == null) return InternalJob.T_INFINITE; return next.getStartTime() - System.currentTimeMillis(); } }
/** * Returns the estimated time in milliseconds before the next job is scheduled * to wake up. The result may be negative. Returns InternalJob.T_INFINITE if * there are no sleeping or waiting jobs. */ protected long sleepHint() { synchronized (lock) { //wait forever if job manager is suspended if (suspended) return InternalJob.T_INFINITE; if (!waiting.isEmpty()) return 0L; //return the anticipated time that the next sleeping job will wake InternalJob next = sleeping.peek(); if (next == null) return InternalJob.T_INFINITE; return next.getStartTime() - System.currentTimeMillis(); } }
/** * Returns the estimated time in milliseconds before the next job is scheduled * to wake up. The result may be negative. Returns InternalJob.T_INFINITE if * there are no sleeping or waiting jobs. */ protected long sleepHint() { synchronized (lock) { //wait forever if job manager is suspended if (suspended) return InternalJob.T_INFINITE; if (!waiting.isEmpty()) return 0L; //return the anticipated time that the next sleeping job will wake InternalJob next = sleeping.peek(); if (next == null) return InternalJob.T_INFINITE; return next.getStartTime() - System.currentTimeMillis(); } }
/** * Returns the estimated time in milliseconds before the next job is scheduled * to wake up. The result may be negative. Returns InternalJob.T_INFINITE if * there are no sleeping or waiting jobs. */ protected long sleepHint() { synchronized (lock) { //wait forever if job manager is suspended if (suspended) return InternalJob.T_INFINITE; if (!waiting.isEmpty()) return 0L; //return the anticipated time that the next sleeping job will wake InternalJob next = sleeping.peek(); if (next == null) return InternalJob.T_INFINITE; return next.getStartTime() - System.currentTimeMillis(); } }
/** * Changes a job priority. */ protected void setPriority(InternalJob job, int newPriority) { synchronized (lock) { int oldPriority = job.getPriority(); if (oldPriority == newPriority) return; job.internalSetPriority(newPriority); //if the job is waiting to run, re-shuffle the queue if (job.getState() == Job.WAITING) { long oldStart = job.getStartTime(); job.setStartTime(oldStart + (delayFor(newPriority) - delayFor(oldPriority))); waiting.resort(job); } } }
/** * Changes a job priority. */ protected void setPriority(InternalJob job, int newPriority) { synchronized (lock) { int oldPriority = job.getPriority(); if (oldPriority == newPriority) return; job.internalSetPriority(newPriority); //if the job is waiting to run, re-shuffle the queue if (job.getState() == Job.WAITING) { long oldStart = job.getStartTime(); job.setStartTime(oldStart + (delayFor(newPriority) - delayFor(oldPriority))); waiting.resort(job); } } }
/** * Changes a job priority. */ protected void setPriority(InternalJob job, int newPriority) { synchronized (lock) { int oldPriority = job.getPriority(); if (oldPriority == newPriority) return; job.internalSetPriority(newPriority); //if the job is waiting to run, re-shuffle the queue if (job.getState() == Job.WAITING) { long oldStart = job.getStartTime(); job.setStartTime(oldStart + (delayFor(newPriority) - delayFor(oldPriority))); waiting.resort(job); } } }
/** * Changes a job priority. */ protected void setPriority(InternalJob job, int newPriority) { synchronized (lock) { int oldPriority = job.getPriority(); if (oldPriority == newPriority) return; job.internalSetPriority(newPriority); //if the job is waiting to run, re-shuffle the queue if (job.getState() == Job.WAITING) { long oldStart = job.getStartTime(); job.setStartTime(oldStart + (delayFor(newPriority) - delayFor(oldPriority))); waiting.resort(job); } } }
job.setProgressMonitor(null); job.setThread(null); rescheduleDelay = job.getStartTime(); changeState(job, Job.NONE);
/** * Indicates that a job was running, and has now finished. 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, boolean notify) { long rescheduleDelay = InternalJob.T_NONE; synchronized (lock) { //if the job is finishing asynchronously, there is nothing more to do for now if (result == Job.ASYNC_FINISH) return; //if job is not known then it cannot be done if (job.getState() == Job.NONE) return; if (JobManager.DEBUG && notify) JobManager.debug("Ending job: " + job); //$NON-NLS-1$ job.setResult(result); job.setProgressMonitor(null); job.setThread(null); rescheduleDelay = job.getStartTime(); changeState(job, Job.NONE); } //notify listeners outside sync block final boolean reschedule = active && rescheduleDelay > InternalJob.T_NONE && job.shouldSchedule(); if (notify) jobListeners.done((Job) job, result, reschedule); //reschedule the job if requested and we are still active if (reschedule) schedule(job, rescheduleDelay, reschedule); }
job.setProgressMonitor(null); job.setThread(null); rescheduleDelay = job.getStartTime(); changeState(job, Job.NONE);
job.setProgressMonitor(null); job.setThread(null); rescheduleDelay = job.getStartTime(); changeState(job, Job.NONE);
while (job != null && job.getStartTime() < now) { job.setStartTime(now + delayFor(job.getPriority())); job.setWaitQueueStamp(waitQueueCounter++);
while (job != null && job.getStartTime() < now) { job.setStartTime(now + delayFor(job.getPriority())); job.setWaitQueueStamp(waitQueueCounter.increment());
while (job != null && job.getStartTime() < now) { job.setStartTime(now + delayFor(job.getPriority())); job.setWaitQueueStamp(waitQueueCounter.increment());
while (job != null && job.getStartTime() < now) { job.setStartTime(now + delayFor(job.getPriority())); job.setWaitQueueStamp(waitQueueCounter.increment());