/** * Submitting a new input for processing. Submitted input jobs are first * buffered, and then concurrently processed by workers. If the buffer is * full, the method blocks until new space is available. * * @param input * the input to be processed * @return {@code true} if the input has been successfully submitted for * computation; the input cannot be submitted, e.g., if * {@link #finish()} has been called * @throws InterruptedException * thrown if interrupted during waiting for space to be * available */ public synchronized boolean submit(I input) throws InterruptedException { if (termination || isInterrupted()) return false; buffer_.put(input); return true; }
jobs = random.nextInt(MAX_JOBS); int sumExpected = 0; if (!computation_.start()) fail(); try { sumExpected += nextInput; for (;;) { if (computation_.submit(nextInput)) break; if (!computation_.isInterrupted()) fail(); computation_.finish(); if (!computation_.start()) fail(); computation_.finish(); if (!computation_.isInterrupted()) { break; if (!computation_.start()) { fail();
void setup(int round, final InterruptMonitor interrupter) { int workers = random.nextInt(round + 1) + 1; factory_ = new TestInputProcessorFactory(interrupter); computation_ = new ConcurrentComputationWithInputs<Integer, TestInputProcessorFactory>( factory_, executor, workers, workers); }
/** * Submitting a new input for processing. Submitted input jobs are first * buffered, and then concurrently processed by workers. If the buffer is * full, the method blocks until new space is available. * * @param input * the input to be processed * @return {@code true} if the input has been successfully submitted for * computation; the input cannot be submitted, e.g., if * {@link #finish()} has been called * @throws InterruptedException * thrown if interrupted during waiting for space to be * available */ public synchronized boolean submit(I input) throws InterruptedException { if (termination || isInterrupted()) return false; buffer_.put(input); return true; }
/** * Submitting a new input for processing. Submitted input jobs are first * buffered, and then concurrently processed by workers. If the buffer is * full, the method blocks until new space is available. * * @param input * the input to be processed * @return {@code true} if the input has been successfully submitted for * computation; the input cannot be submitted, e.g., if * {@link #finish()} has been called * @throws InterruptedException * thrown if interrupted during waiting for space to be * available */ public synchronized boolean submit(I input) throws InterruptedException { if (termination || isInterrupted()) return false; buffer_.put(input); return true; }