/** Changes the state of the task to be running. Any call after this * one and before notifyFinished to waitFinished blocks. * @since 1.5 */ protected final void notifyRunning() { synchronized (this) { RequestProcessor.logger().log(Level.FINE, "notifyRunning: {0}", this); // NOI18N this.finished = false; notifyAll(); } }
public ThreadGroup getTopLevelThreadGroup() { ThreadGroup orig = java.security.AccessController.doPrivileged(this); ThreadGroup nuova = null; try { Class<?> appContext = Class.forName("sun.awt.AppContext"); Method instance = appContext.getMethod("getAppContext"); Method getTG = appContext.getMethod("getThreadGroup"); nuova = (ThreadGroup) getTG.invoke(instance.invoke(null)); } catch (Exception exception) { logger().log(Level.FINE, "Cannot access sun.awt.AppContext", exception); return orig; } assert nuova != null; if (nuova != orig) { logger().log(Level.WARNING, "AppContext group {0} differs from originally used {1}", new Object[]{nuova, orig}); } return nuova; } @Override
/** See #20467. */ private static void doNotify(RequestProcessor.Task todo, Throwable ex) { if (SLOW) { Item item = todo.item; if (item != null && item.message == null) { item.message = "task failed due to: " + ex; item.initCause(ex); ex = item; } } logger().log(Level.SEVERE, "Error in RequestProcessor " + todo.debug(), ex); }
/** Notify all waiters that this task has finished. * @see #run */ protected final void notifyFinished() { Iterator it; synchronized (this) { finished = true; RequestProcessor.logger().log(Level.FINE, "notifyFinished: {0}", this); // NOI18N notifyAll(); // fire the listeners if (list == null) { return; } it = ((HashSet) list.clone()).iterator(); } while (it.hasNext()) { TaskListener l = (TaskListener) it.next(); l.taskFinished(this); } }
private void registerParallel(Task todo, RequestProcessor rp) { if (rp.warnParallel == 0 || todo.run == null) { return; } final Class<? extends Runnable> c = todo.run.getClass(); AtomicInteger number; synchronized (rp.processorLock) { if (rp.inParallel == null) { rp.inParallel = new WeakHashMap<Class<? extends Runnable>,AtomicInteger>(); } number = rp.inParallel.get(c); if (number == null) { rp.inParallel.put(c, number = new AtomicInteger(1)); } else { number.incrementAndGet(); } } if (number.get() >= rp.warnParallel && warnedClasses.put(c, "") == null) { final String msg = "Too many " + c.getName() + " (" + number + ") in shared RequestProcessor; create your own"; // NOI18N Exception ex = null; Item itm = todo.item; if (itm != null) { ex = new IllegalStateException(msg); ex.setStackTrace(itm.getStackTrace()); } logger().log(Level.WARNING, msg, ex); } }
/** Place the Task to the queue of pending tasks for immediate processing. * If there is no other Task planned, this task is immediatelly processed * in the Processor. */ void enqueue(Item item) { Logger em = logger(); boolean loggable = em.isLoggable(Level.FINE); boolean wasNull; synchronized (processorLock) { wasNull = item.getTask() == null; if (!wasNull) { prioritizedEnqueue(item); if (running < throughput) { running++; Processor proc = Processor.get(); processors.add(proc); proc.setName(name); proc.attachTo(this); } } } if (loggable) { if (wasNull) { em.log(Level.FINE, "Null task for item {0}", item); // NOI18N } else { em.log(Level.FINE, "Item enqueued: {0} status: {1}", new Object[]{item.action, item.enqueued}); // NOI18N } } }
boolean toRun; Logger em = logger(); boolean loggable = em.isLoggable(Level.FINE);
Logger em = logger(); boolean loggable = em.isLoggable(Level.FINE);
/** Changes the state of the task to be running. Any call after this * one and before notifyFinished to waitFinished blocks. * @since 1.5 */ protected final void notifyRunning() { synchronized (this) { if (RequestProcessor.logger().isLoggable(Level.FINE)) { RequestProcessor.logger().fine("notifyRunning: " + this); // NOI18N } this.finished = false; notifyAll(); } }
/** Changes the state of the task to be running. Any call after this * one and before notifyFinished to waitFinished blocks. * @since 1.5 */ protected final void notifyRunning() { synchronized (this) { RequestProcessor.logger().log(Level.FINE, "notifyRunning: {0}", this); // NOI18N this.finished = false; notifyAll(); } }
/** @see "#20467" */ private static void doNotify(RequestProcessor.Task todo, Throwable ex) { logger().log(Level.SEVERE, null, ex); if (SLOW) { logger.log(Level.SEVERE, null, todo.item); } }
public ThreadGroup getTopLevelThreadGroup() { ThreadGroup orig = java.security.AccessController.doPrivileged(this); ThreadGroup nuova = null; try { Class<?> appContext = Class.forName("sun.awt.AppContext"); Method instance = appContext.getMethod("getAppContext"); Method getTG = appContext.getMethod("getThreadGroup"); nuova = (ThreadGroup) getTG.invoke(instance.invoke(null)); } catch (Exception exception) { logger().log(Level.FINE, "Cannot access sun.awt.AppContext", exception); return orig; } assert nuova != null; if (nuova != orig) { logger().log(Level.WARNING, "AppContext group {0} differs from originally used {1}", new Object[]{nuova, orig}); } return nuova; } @Override
/** Notify all waiters that this task has finished. * @see #run */ protected final void notifyFinished() { Iterator it; synchronized (this) { finished = true; if (RequestProcessor.logger().isLoggable(Level.FINE)) { RequestProcessor.logger().fine("notifyFinished: " + this); // NOI18N } notifyAll(); // fire the listeners if (list == null) { return; } it = ((HashSet) list.clone()).iterator(); } while (it.hasNext()) { TaskListener l = (TaskListener) it.next(); l.taskFinished(this); } }
/** See #20467. */ private static void doNotify(RequestProcessor.Task todo, Throwable ex) { if (SLOW) { Item item = todo.item; if (item != null && item.message == null) { item.message = "task failed due to: " + ex; item.initCause(ex); ex = item; } } logger().log(Level.SEVERE, "Error in RequestProcessor " + todo.debug(), ex); }
/** Notify all waiters that this task has finished. * @see #run */ protected final void notifyFinished() { Iterator it; synchronized (this) { finished = true; RequestProcessor.logger().log(Level.FINE, "notifyFinished: {0}", this); // NOI18N notifyAll(); // fire the listeners if (list == null) { return; } it = ((HashSet) list.clone()).iterator(); } while (it.hasNext()) { TaskListener l = (TaskListener) it.next(); l.taskFinished(this); } }
private void registerParallel(Task todo, RequestProcessor rp) { if (rp.warnParallel == 0 || todo.run == null) { return; } final Class<? extends Runnable> c = todo.run.getClass(); AtomicInteger number; synchronized (rp.processorLock) { if (rp.inParallel == null) { rp.inParallel = new WeakHashMap<Class<? extends Runnable>,AtomicInteger>(); } number = rp.inParallel.get(c); if (number == null) { rp.inParallel.put(c, number = new AtomicInteger(1)); } else { number.incrementAndGet(); } } if (number.get() >= rp.warnParallel && warnedClasses.put(c, "") == null) { final String msg = "Too many " + c.getName() + " (" + number + ") in shared RequestProcessor; create your own"; // NOI18N Exception ex = null; Item itm = todo.item; if (itm != null) { ex = new IllegalStateException(msg); ex.setStackTrace(itm.getStackTrace()); } logger().log(Level.WARNING, msg, ex); } }
boolean toRun; Logger em = logger(); boolean loggable = em.isLoggable(Level.FINE);
/** Place the Task to the queue of pending tasks for immediate processing. * If there is no other Task planned, this task is immediatelly processed * in the Processor. */ void enqueue(Item item) { Logger em = logger(); boolean loggable = em.isLoggable(Level.FINE); synchronized (processorLock) { if (item.getTask() == null) { if (loggable) { em.fine("Null task for item " + item); // NOI18N } return; } prioritizedEnqueue(item); if (running < throughput) { running++; Processor proc = Processor.get(); processors.add(proc); proc.setName(name); proc.attachTo(this); } } if (loggable) { em.fine("Item enqueued: " + item.action + " status: " + item.enqueued); // NOI18N } }
boolean toRun; Logger em = logger(); boolean loggable = em.isLoggable(Level.FINE);
/** Place the Task to the queue of pending tasks for immediate processing. * If there is no other Task planned, this task is immediatelly processed * in the Processor. */ void enqueue(Item item) { Logger em = logger(); boolean loggable = em.isLoggable(Level.FINE); boolean wasNull; synchronized (processorLock) { wasNull = item.getTask() == null; if (!wasNull) { prioritizedEnqueue(item); if (running < throughput) { running++; Processor proc = Processor.get(); processors.add(proc); proc.setName(name); proc.attachTo(this); } } } if (loggable) { if (wasNull) { em.log(Level.FINE, "Null task for item {0}", item); // NOI18N } else { em.log(Level.FINE, "Item enqueued: {0} status: {1}", new Object[]{item.action, item.enqueued}); // NOI18N } } }