/** * Schedule the concurrent collector threads. If this is called from within a collection interval * the threads must not be started until after the interval is complete. */ private static void scheduleConcurrentWorkers() { concurrentWorkersLock.acquire(); if (!allowConcurrentWorkersActive) { if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(concurrentWorkersActive == 0); allowConcurrentWorkersActive = true; } concurrentWorkersLock.release(); VM.collection.scheduleConcurrentWorkers(); }
/** * Notify that the current thread believes that a concurrent collection phase is complete. * * @return True if this was the last thread. */ public static boolean completeConcurrentPhase() { boolean result = false; concurrentWorkersLock.acquire(); if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(allowConcurrentWorkersActive); concurrentWorkersActive--; if (concurrentWorkersActive == 0) { allowConcurrentWorkersActive = false; result = true; } if (Options.verbose.getValue() >= 3) { Log.write("< Concurrent worker "); Log.write(concurrentWorkersActive); Log.write(" completed phase "); Log.write(getName(concurrentPhaseId)); Log.writeln(" >"); } concurrentWorkersLock.release(); return result; }
/** Attempt to begin execution of a concurrent collection phase. */ public static boolean startConcurrentPhase() { boolean result = false; concurrentWorkersLock.acquire(); if (concurrentPhaseActive()) { if (allowConcurrentWorkersActive) { concurrentWorkersActive++; result = true; } VM.activePlan.collector().clearResetConcurrentWork(); } if (Options.verbose.getValue() >= 2) { if (result) { Log.write("< Concurrent worker "); Log.write(concurrentWorkersActive - 1); Log.write(" started phase "); Log.write(getName(concurrentPhaseId)); Log.writeln(" >"); } else { Log.writeln("< worker failed in attempt to start phase >"); } } concurrentWorkersLock.release(); return result; }
/** Release the lock. */ protected final void unlock() { lock.release(); }
/** Acquire the lock. */ protected final void lock() { lock.acquire(); }
/** * Add to the total cumulative committed page count. * * @param pages The number of pages to be added. */ private static void addToCommitted(int pages) { classLock.acquire(); cumulativeCommitted += pages; classLock.release(); }