/** * Reset all of this job's fields so it can be reused. Returns false if * reuse is not possible * @GuardedBy("JobManager.implicitJobs") */ boolean recycle() { //don't recycle if still running for any reason if (getState() != Job.NONE) return false; //clear and reset all fields acquireRule = isRunning = isBlocked = false; realJob = null; setRule(null); setThread(null); if (ruleStack.length != 2) ruleStack = new ISchedulingRule[2]; else ruleStack[0] = ruleStack[1] = null; top = -1; return true; }
/** * Reset all of this job's fields so it can be reused. Returns false if * reuse is not possible * @GuardedBy("JobManager.implicitJobs") */ boolean recycle() { //don't recycle if still running for any reason if (getState() != Job.NONE) return false; //clear and reset all fields acquireRule = isRunning = isBlocked = false; realJob = null; setRule(null); setThread(null); if (ruleStack.length != 2) ruleStack = new ISchedulingRule[2]; else ruleStack[0] = ruleStack[1] = null; top = -1; return true; }
/** * Reset all of this job's fields so it can be reused. Returns false if * reuse is not possible * @GuardedBy("JobManager.implicitJobs") */ boolean recycle() { //don't recycle if still running for any reason if (getState() != Job.NONE) return false; //clear and reset all fields acquireRule = isRunning = isBlocked = false; realJob = null; setRule(null); setThread(null); if (ruleStack.length != 2) ruleStack = new ISchedulingRule[2]; else ruleStack[0] = ruleStack[1] = null; top = -1; return true; }
/** * Implements IJobManager#transferRule(ISchedulingRule, Thread) */ synchronized void transfer(ISchedulingRule rule, Thread destinationThread) { //nothing to do for null if (rule == null) return; final Thread currentThread = Thread.currentThread(); //nothing to do if transferring to the same thread if (currentThread == destinationThread) return; //ensure destination thread doesn't already have a rule ThreadJob target = threadJobs.get(destinationThread); Assert.isLegal(target == null, "Transfer rule to job that already owns a rule"); //$NON-NLS-1$ //ensure calling thread owns the job being transferred ThreadJob source = threadJobs.get(currentThread); Assert.isNotNull(source, "transferRule without beginRule"); //$NON-NLS-1$ Assert.isLegal(source.getRule() == rule, "transferred rule " + rule + " does not match beginRule: " + source.getRule()); //$NON-NLS-1$ //$NON-NLS-2$ // transfer the thread job without ending it source.setThread(destinationThread); threadJobs.remove(currentThread); threadJobs.put(destinationThread, source); // transfer lock if (source.acquireRule) { manager.getLockManager().removeLockThread(currentThread, rule); manager.getLockManager().addLockThread(destinationThread, rule); } // Wake up any blocked jobs (waiting within yield or joinRun) waiting on // this rule notifyWaitingThreadJobs(source); }
/** * Implements IJobManager#transferRule(ISchedulingRule, Thread) */ synchronized void transfer(ISchedulingRule rule, Thread destinationThread) { //nothing to do for null if (rule == null) return; final Thread currentThread = Thread.currentThread(); //nothing to do if transferring to the same thread if (currentThread == destinationThread) return; //ensure destination thread doesn't already have a rule ThreadJob target = (ThreadJob) threadJobs.get(destinationThread); Assert.isLegal(target == null, "Transfer rule to job that already owns a rule"); //$NON-NLS-1$ //ensure calling thread owns the job being transferred ThreadJob source = (ThreadJob) threadJobs.get(currentThread); Assert.isNotNull(source, "transferRule without beginRule"); //$NON-NLS-1$ Assert.isLegal(source.getRule() == rule, "transferred rule " + rule + " does not match beginRule: " + source.getRule()); //$NON-NLS-1$ //$NON-NLS-2$ // transfer the thread job without ending it source.setThread(destinationThread); threadJobs.remove(currentThread); threadJobs.put(destinationThread, source); // transfer lock if (source.acquireRule) { manager.getLockManager().removeLockThread(currentThread, rule); manager.getLockManager().addLockThread(destinationThread, rule); } // Wake up any blocked jobs (waiting within yield or joinRun) waiting on // this rule notifyWaitingThreadJobs(source); }
/** * Implements IJobManager#transferRule(ISchedulingRule, Thread) */ synchronized void transfer(ISchedulingRule rule, Thread destinationThread) { //nothing to do for null if (rule == null) return; final Thread currentThread = Thread.currentThread(); //nothing to do if transferring to the same thread if (currentThread == destinationThread) return; //ensure destination thread doesn't already have a rule ThreadJob target = threadJobs.get(destinationThread); Assert.isLegal(target == null, "Transfer rule to job that already owns a rule"); //$NON-NLS-1$ //ensure calling thread owns the job being transferred ThreadJob source = threadJobs.get(currentThread); Assert.isNotNull(source, "transferRule without beginRule"); //$NON-NLS-1$ Assert.isLegal(source.getRule() == rule, "transferred rule " + rule + " does not match beginRule: " + source.getRule()); //$NON-NLS-1$ //$NON-NLS-2$ // transfer the thread job without ending it source.setThread(destinationThread); threadJobs.remove(currentThread); threadJobs.put(destinationThread, source); // transfer lock if (source.acquireRule) { manager.getLockManager().removeLockThread(currentThread, rule); manager.getLockManager().addLockThread(destinationThread, rule); } // Wake up any blocked jobs (waiting within yield or joinRun) waiting on // this rule notifyWaitingThreadJobs(source); }
threadJob.setThread(currentThread);
threadJob.setThread(currentThread);
threadJob.setThread(currentThread);