@Test public void addProblemFactChangesWithoutDaemon() { AtomicInteger count = new AtomicInteger(0); BasicPlumbingTermination basicPlumbingTermination = new BasicPlumbingTermination(false); assertEquals(false, basicPlumbingTermination.waitForRestartSolverDecision()); basicPlumbingTermination.addProblemFactChanges(Arrays.asList( scoreDirector -> count.getAndIncrement(), scoreDirector -> count.getAndAdd(20) )); assertEquals(true, basicPlumbingTermination.waitForRestartSolverDecision()); assertEquals(0, count.get()); basicPlumbingTermination.startProblemFactChangesProcessing().removeIf(problemFactChange -> { problemFactChange.doChange(null); return true; }); assertEquals(false, basicPlumbingTermination.waitForRestartSolverDecision()); assertEquals(21, count.get()); }
@Test public void addProblemFactChangeWithoutDaemon() { AtomicInteger count = new AtomicInteger(0); BasicPlumbingTermination basicPlumbingTermination = new BasicPlumbingTermination(false); assertEquals(false, basicPlumbingTermination.waitForRestartSolverDecision()); basicPlumbingTermination.addProblemFactChange(scoreDirector -> count.getAndIncrement()); assertEquals(true, basicPlumbingTermination.waitForRestartSolverDecision()); assertEquals(0, count.get()); basicPlumbingTermination.startProblemFactChangesProcessing().removeIf(problemFactChange -> { problemFactChange.doChange(null); return true; }); assertEquals(false, basicPlumbingTermination.waitForRestartSolverDecision()); assertEquals(1, count.get()); }
@Override public void unbind(String sessionId) { entries.removeIf(entry -> entry.sessionId.equals(sessionId)); delegate.unbind(sessionId); }
@Override public void unbind(String sessionId) { entries.removeIf(entry -> entry.sessionId.equals(sessionId)); delegate.unbind(sessionId); }
protected void resetTimeout(long timeout) { timer.timeout(timeout); events.removeIf(e -> e.type == Type.TIMEOUT); }
/** * Removes all task for the user with name {@code aUsername} from the scheduler's queue. * @param aUserName The name of the user whose tasks will be removed. */ public synchronized void stopAllTasksForUser(String aUserName) { // TODO: Stop the running tasks also executor.getQueue().removeIf(e -> { Task task = (Task) e; return task.getUser().getUsername().equals(aUserName); }); }
/** * Removes all task for the user with name {@code aUsername} from the scheduler's queue. * @param aUserName The name of the user whose tasks will be removed. */ public synchronized void stopAllTasksForUser(String aUserName) { // TODO: Stop the running tasks also executor.getQueue().removeIf(e -> { Task task = (Task) e; return task.getUser().getUsername().equals(aUserName); }); }