void maybeStartSpinningWorker() { // in general the workers manage spinningCount directly; however if it is zero, we increment it atomically // ourselves to avoid starting a worker unless we have to int current = spinningCount.get(); if (current == 0 && spinningCount.compareAndSet(0, 1)) schedule(Work.SPINNING); }
private static LocalAwareExecutorService multiThreadedLowSignalStage(Stage stage, int numThreads) { return SharedExecutorPool.SHARED.newExecutor(numThreads, Integer.MAX_VALUE, stage.getJmxType(), stage.getJmxName()); }
pool.maybeStartSpinningWorker(); pool.schedule(new Work(this)); totalBlocked.incrementAndGet(); currentlyBlocked.incrementAndGet();
pool.maybeStartSpinningWorker(); pool.schedule(new Work(this));
void maybeStartSpinningWorker() { // in general the workers manage spinningCount directly; however if it is zero, we increment it atomically // ourselves to avoid starting a worker unless we have to int current = spinningCount.get(); if (current == 0 && spinningCount.compareAndSet(0, 1)) schedule(Work.SPINNING); } }
pool.maybeStartSpinningWorker(); pool.schedule(new Work(this));
private static LocalAwareExecutorService multiThreadedLowSignalStage(Stage stage, int numThreads) { return SharedExecutorPool.SHARED.newExecutor(numThreads, Integer.MAX_VALUE, stage.getJmxType(), stage.getJmxName()); }
void maybeStartSpinningWorker() { // in general the workers manage spinningCount directly; however if it is zero, we increment it atomically // ourselves to avoid starting a worker unless we have to int current = spinningCount.get(); if (current == 0 && spinningCount.compareAndSet(0, 1)) schedule(Work.SPINNING); }
pool.maybeStartSpinningWorker(); pool.schedule(new Work(this));
private static LocalAwareExecutorService multiThreadedLowSignalStage(Stage stage, int numThreads) { return SharedExecutorPool.SHARED.newExecutor(numThreads, Integer.MAX_VALUE, stage.getJmxType(), stage.getJmxName()); }
void maybeStartSpinningWorker() { // in general the workers manage spinningCount directly; however if it is zero, we increment it atomically // ourselves to avoid starting a worker unless we have to int current = spinningCount.get(); if (current == 0 && spinningCount.compareAndSet(0, 1)) schedule(Work.SPINNING); }
boolean maybeSchedule() { if (pool.spinningCount.get() > 0 || !takeWorkPermit(true)) return false; pool.schedule(new Work(this)); return true; }
boolean maybeSchedule() { if (pool.spinningCount.get() > 0 || !takeWorkPermit(true)) return false; pool.schedule(new Work(this)); return true; }
boolean maybeSchedule() { if (pool.spinningCount.get() > 0 || !takeWorkPermit(true)) return false; pool.schedule(new Work(this)); return true; }
boolean maybeSchedule() { if (pool.spinningCount.get() > 0 || !takeWorkPermit(true)) return false; pool.schedule(new Work(this)); return true; }
private void maybeStop(long stopCheck, long now) { long delta = now - stopCheck; if (delta <= 0) { // if stopCheck has caught up with present, we've been spinning too much, so if we can atomically // set it to the past again, we should stop a worker if (pool.stopCheck.compareAndSet(stopCheck, now - stopCheckInterval)) { // try and stop ourselves; // if we've already been assigned work stop another worker if (!assign(Work.STOP_SIGNALLED, true)) pool.schedule(Work.STOP_SIGNALLED); } } else if (soleSpinnerSpinTime > stopCheckInterval && pool.spinningCount.get() == 1) { // permit self-stopping assign(Work.STOP_SIGNALLED, true); } else { // if stop check has gotten too far behind present, update it so new spins can affect it while (delta > stopCheckInterval * 2 && !pool.stopCheck.compareAndSet(stopCheck, now - stopCheckInterval)) { stopCheck = pool.stopCheck.get(); delta = now - stopCheck; } } }
private void maybeStop(long stopCheck, long now) { long delta = now - stopCheck; if (delta <= 0) { // if stopCheck has caught up with present, we've been spinning too much, so if we can atomically // set it to the past again, we should stop a worker if (pool.stopCheck.compareAndSet(stopCheck, now - stopCheckInterval)) { // try and stop ourselves; // if we've already been assigned work stop another worker if (!assign(Work.STOP_SIGNALLED, true)) pool.schedule(Work.STOP_SIGNALLED); } } else if (soleSpinnerSpinTime > stopCheckInterval && pool.spinningCount.get() == 1) { // permit self-stopping assign(Work.STOP_SIGNALLED, true); } else { // if stop check has gotten too far behind present, update it so new spins can affect it while (delta > stopCheckInterval * 2 && !pool.stopCheck.compareAndSet(stopCheck, now - stopCheckInterval)) { stopCheck = pool.stopCheck.get(); delta = now - stopCheck; } } }
private void maybeStop(long stopCheck, long now) { long delta = now - stopCheck; if (delta <= 0) { // if stopCheck has caught up with present, we've been spinning too much, so if we can atomically // set it to the past again, we should stop a worker if (pool.stopCheck.compareAndSet(stopCheck, now - stopCheckInterval)) { // try and stop ourselves; // if we've already been assigned work stop another worker if (!assign(Work.STOP_SIGNALLED, true)) pool.schedule(Work.STOP_SIGNALLED); } } else if (soleSpinnerSpinTime > stopCheckInterval && pool.spinningCount.get() == 1) { // permit self-stopping assign(Work.STOP_SIGNALLED, true); } else { // if stop check has gotten too far behind present, update it so new spins can affect it while (delta > stopCheckInterval * 2 && !pool.stopCheck.compareAndSet(stopCheck, now - stopCheckInterval)) { stopCheck = pool.stopCheck.get(); delta = now - stopCheck; } } }
private void maybeStop(long stopCheck, long now) { long delta = now - stopCheck; if (delta <= 0) { // if stopCheck has caught up with present, we've been spinning too much, so if we can atomically // set it to the past again, we should stop a worker if (pool.stopCheck.compareAndSet(stopCheck, now - stopCheckInterval)) { // try and stop ourselves; // if we've already been assigned work stop another worker if (!assign(Work.STOP_SIGNALLED, true)) pool.schedule(Work.STOP_SIGNALLED); } } else if (soleSpinnerSpinTime > stopCheckInterval && pool.spinningCount.get() == 1) { // permit self-stopping assign(Work.STOP_SIGNALLED, true); } else { // if stop check has gotten too far behind present, update it so new spins can affect it while (delta > stopCheckInterval * 2 && !pool.stopCheck.compareAndSet(stopCheck, now - stopCheckInterval)) { stopCheck = pool.stopCheck.get(); delta = now - stopCheck; } } }
private boolean selfAssign() { // if we aren't permitted to assign in this state, fail if (!get().canAssign(true)) return false; for (SEPExecutor exec : pool.executors) { if (exec.takeWorkPermit(true)) { Work work = new Work(exec); // we successfully started work on this executor, so we must either assign it to ourselves or ... if (assign(work, true)) return true; // ... if we fail, schedule it to another worker pool.schedule(work); // and return success as we must have already been assigned a task assert get().assigned != null; return true; } } return false; }