while (writer.hasPendingMerges() && mergeThreadCount() >= maxMergeCount) {
/** Return the priority that merge threads run at. */ public synchronized void setMergeThreadPriority(int pri) { if (pri > Thread.MAX_PRIORITY || pri < Thread.MIN_PRIORITY) throw new IllegalArgumentException("priority must be in range " + Thread.MIN_PRIORITY + " .. " + Thread.MAX_PRIORITY + " inclusive"); mergeThreadPriority = pri; final int numThreads = mergeThreadCount(); for(int i=0;i<numThreads;i++) { MergeThread merge = (MergeThread) mergeThreads.get(i); merge.setThreadPriority(pri); } }
/** Return the priority that merge threads run at. */ public synchronized void setMergeThreadPriority(int pri) { if (pri > Thread.MAX_PRIORITY || pri < Thread.MIN_PRIORITY) throw new IllegalArgumentException("priority must be in range " + Thread.MIN_PRIORITY + " .. " + Thread.MAX_PRIORITY + " inclusive"); mergeThreadPriority = pri; final int numThreads = mergeThreadCount(); for(int i=0;i<numThreads;i++) { MergeThread merge = (MergeThread) mergeThreads.get(i); merge.setThreadPriority(pri); } }
/** Used for testing */ private void addMyself() { synchronized(allInstances) { final int size=0; int upto = 0; for(int i=0;i<size;i++) { final ConcurrentMergeScheduler other = (ConcurrentMergeScheduler) allInstances.get(i); if (!(other.closed && 0 == other.mergeThreadCount())) // Keep this one for now: it still has threads or // may spawn new threads allInstances.set(upto++, other); } allInstances.subList(upto, allInstances.size()).clear(); allInstances.add(this); } }
/** Used for testing */ private void addMyself() { synchronized(allInstances) { final int size=0; int upto = 0; for(int i=0;i<size;i++) { final ConcurrentMergeScheduler other = (ConcurrentMergeScheduler) allInstances.get(i); if (!(other.closed && 0 == other.mergeThreadCount())) // Keep this one for now: it still has threads or // may spawn new threads allInstances.set(upto++, other); } allInstances.subList(upto, allInstances.size()).clear(); allInstances.add(this); } }
public synchronized void sync() { while(mergeThreadCount() > 0) { message("now wait for threads; currently " + mergeThreads.size() + " still running"); final int count = mergeThreads.size(); for(int i=0;i<count;i++) message(" " + i + ": " + ((MergeThread) mergeThreads.get(i))); try { wait(); } catch (InterruptedException e) { } } } private synchronized int mergeThreadCount() {
public synchronized void sync() { while(mergeThreadCount() > 0) { message("now wait for threads; currently " + mergeThreads.size() + " still running"); final int count = mergeThreads.size(); for(int i=0;i<count;i++) message(" " + i + ": " + ((MergeThread) mergeThreads.get(i))); try { wait(); } catch (InterruptedException e) { } } } private synchronized int mergeThreadCount() {
while (writer.hasPendingMerges() && mergeThreadCount() >= maxMergeCount) {
while (writer.hasPendingMerges() && mergeThreadCount() >= maxMergeCount) {
while (writer.hasPendingMerges() && mergeThreadCount() >= maxMergeCount) {
while (mergeThreadCount() >= maxThreadCount) { message(" too many merge threads running; stalling..."); try { assert mergeThreadCount() < maxThreadCount;
while (mergeThreadCount() >= maxThreadCount) { message(" too many merge threads running; stalling..."); try { assert mergeThreadCount() < maxThreadCount;