/** * Attempts to execute all the listeners in {@link #listeners} while not holding the {@link * #monitor}. */ private void dispatchListenerEvents() { if (!monitor.isOccupiedByCurrentThread()) { listeners.dispatch(); } }
/** Attempts to execute all the listeners in {@link #listeners}. */ void dispatchListenerEvents() { checkState( !monitor.isOccupiedByCurrentThread(), "It is incorrect to execute listeners with the monitor held."); listeners.dispatch(); }
/** * Attempts to execute all the listeners in {@link #listeners} while not holding the {@link * #monitor}. */ private void dispatchListenerEvents() { if (!monitor.isOccupiedByCurrentThread()) { listeners.dispatch(); } }
/** Attempts to execute all the listeners in {@link #listeners}. */ void dispatchListenerEvents() { checkState( !monitor.isOccupiedByCurrentThread(), "It is incorrect to execute listeners with the monitor held."); listeners.dispatch(); }
/** Attempts to execute all the listeners in {@link #listeners}. */ void dispatchListenerEvents() { checkState( !monitor.isOccupiedByCurrentThread(), "It is incorrect to execute listeners with the monitor held."); listeners.dispatch(); }
/** * Attempts to execute all the listeners in {@link #listeners} while not holding the {@link * #monitor}. */ private void dispatchListenerEvents() { if (!monitor.isOccupiedByCurrentThread()) { listeners.dispatch(); } }
@Override public void run() { try { actualIsOccupied.set(monitor.isOccupied()); actualIsOccupiedByCurrentThread.set(monitor.isOccupiedByCurrentThread()); actualOccupiedDepth.set(monitor.getOccupiedDepth()); } catch (Throwable t) { thrown.set(t); } } }));
private void runEnterTest() { assertFalse(Thread.currentThread().isInterrupted()); assertFalse(monitor.isOccupiedByCurrentThread()); doEnterScenarioSetUp(); boolean interruptedBeforeCall = Thread.currentThread().isInterrupted(); Outcome actualOutcome = doCall(); boolean occupiedAfterCall = monitor.isOccupiedByCurrentThread(); boolean interruptedAfterCall = Thread.currentThread().isInterrupted(); if (occupiedAfterCall) { guard.setSatisfied(true); monitor.leave(); assertFalse(monitor.isOccupiedByCurrentThread()); } assertEquals(expectedOutcome, actualOutcome); assertEquals(expectedOutcome == Outcome.SUCCESS, occupiedAfterCall); assertEquals( interruptedBeforeCall && expectedOutcome != Outcome.INTERRUPT, interruptedAfterCall); }
private void runWaitTest() { assertFalse(Thread.currentThread().isInterrupted()); assertFalse(monitor.isOccupiedByCurrentThread()); monitor.enter(); try { assertTrue(monitor.isOccupiedByCurrentThread()); doWaitScenarioSetUp(); boolean interruptedBeforeCall = Thread.currentThread().isInterrupted(); Outcome actualOutcome = doCall(); boolean occupiedAfterCall = monitor.isOccupiedByCurrentThread(); boolean interruptedAfterCall = Thread.currentThread().isInterrupted(); assertEquals(expectedOutcome, actualOutcome); assertTrue(occupiedAfterCall); assertEquals( interruptedBeforeCall && expectedOutcome != Outcome.INTERRUPT, interruptedAfterCall); } finally { guard.setSatisfied(true); monitor.leave(); assertFalse(monitor.isOccupiedByCurrentThread()); } }
private static void verifyOccupiedMethodsInCurrentThread( Monitor monitor, boolean expectedIsOccupied, boolean expectedIsOccupiedByCurrentThread, int expectedOccupiedDepth) { assertEquals(expectedIsOccupied, monitor.isOccupied()); assertEquals(expectedIsOccupiedByCurrentThread, monitor.isOccupiedByCurrentThread()); assertEquals(expectedOccupiedDepth, monitor.getOccupiedDepth()); }
@Override public boolean block() throws InterruptedException { if (!monitor.isOccupiedByCurrentThread()) monitor.enter(); return true; }
@Override public boolean isReleasable() { return monitor.isOccupiedByCurrentThread() || monitor.tryEnter(); } }
/** * Attempts to execute all the listeners in {@link #listeners} while not holding the {@link * #monitor}. */ private void dispatchListenerEvents() { if (!monitor.isOccupiedByCurrentThread()) { listeners.dispatch(); } }
/** * Attempts to execute all the listeners in {@link #listeners} while not holding the * {@link #monitor}. */ private void executeListeners() { if (!monitor.isOccupiedByCurrentThread()) { // iterate by index to avoid concurrent modification exceptions for (int i = 0; i < listeners.size(); i++) { listeners.get(i).execute(); } } }
/** Attempts to execute all the listeners in {@link #listeners}. */ void dispatchListenerEvents() { checkState( !monitor.isOccupiedByCurrentThread(), "It is incorrect to execute listeners with the monitor held."); listeners.dispatch(); }
/** Attempts to execute all the listeners in {@link #queuedListeners}. */ private void executeListeners() { checkState(!monitor.isOccupiedByCurrentThread(), "It is incorrect to execute listeners with the monitor held."); queuedListeners.execute(); } }
/** * Attempts to execute all the listeners in {@link #queuedListeners} while not holding the * {@link #monitor}. */ private void executeListeners() { if (!monitor.isOccupiedByCurrentThread()) { queuedListeners.execute(); } }
/** * Attempts to execute all the listeners in {@link #queuedListeners} while not holding the * {@link #monitor}. */ private void executeListeners() { if (!monitor.isOccupiedByCurrentThread()) { queuedListeners.execute(); } }
/** Attempts to execute all the listeners in {@link #queuedListeners}. */ private void executeListeners() { checkState(!monitor.isOccupiedByCurrentThread(), "It is incorrect to execute listeners with the monitor held."); queuedListeners.execute(); } }
@Override public void run() { try { actualIsOccupied.set(monitor.isOccupied()); actualIsOccupiedByCurrentThread.set(monitor.isOccupiedByCurrentThread()); actualOccupiedDepth.set(monitor.getOccupiedDepth()); } catch (Throwable t) { thrown.set(t); } } }));