@Test public void on_interrupt_throws_InterruptedException() throws Exception { IpcReader<Consumer<String>> reader = target -> PollResult.NO_NEW_MESSAGES; Consumer<String> target = s -> { }; Thread.currentThread().interrupt(); thrown.expect(InterruptedException.class); IpcReaders.decodeAll(reader, target); }
public static <T> void decodeAll(IpcReader<T> reader, T target) throws InterruptedException { WaitStrategy waitStrategy = new ProgressiveSleepWaitStrategy(); while (true) { PollResult result = reader.poll(target); if (result == PollResult.NO_NEW_MESSAGES) { waitStrategy.snooze(); } if (result == PollResult.HAD_SOME_MESSAGES) { waitStrategy.reset(); } if (result == PollResult.END_OF_STREAM) { return; } if (Thread.interrupted()) { throw new InterruptedException(); } } }
IpcReaders { public static <T> void decodeAll(IpcReader<T> reader, T target) throws InterruptedException { WaitStrategy waitStrategy = new ProgressiveSleepWaitStrategy(); while (true) { PollResult result = reader.poll(target); if (result == PollResult.NO_NEW_MESSAGES) { waitStrategy.snooze(); } if (result == PollResult.HAD_SOME_MESSAGES) { waitStrategy.reset(); } if (result == PollResult.END_OF_STREAM) { return; } if (Thread.interrupted()) { throw new InterruptedException(); } } } }
IpcReaders { public static <T> void decodeAll(IpcReader<T> reader, T target) throws InterruptedException { WaitStrategy waitStrategy = new ProgressiveSleepWaitStrategy(); while (true) { PollResult result = reader.poll(target); if (result == PollResult.NO_NEW_MESSAGES) { waitStrategy.snooze(); } if (result == PollResult.HAD_SOME_MESSAGES) { waitStrategy.reset(); } if (result == PollResult.END_OF_STREAM) { return; } if (Thread.interrupted()) { throw new InterruptedException(); } } }  }
IpcReaders { public static <T> void decodeAll(IpcReader<T> reader, T target) throws InterruptedException { WaitStrategy waitStrategy = new ProgressiveSleepWaitStrategy(); while (true) { PollResult result = reader.poll(target); if (result == PollResult.NO_NEW_MESSAGES) { waitStrategy.snooze(); } if (result == PollResult.HAD_SOME_MESSAGES) { waitStrategy.reset(); } if (result == PollResult.END_OF_STREAM) { return; } if (Thread.interrupted()) { throw new InterruptedException(); } } }  static void decodeAll(IpcReader<T> reader, T target); }
IpcReaders { public static <T> void decodeAll(IpcReader<T> reader, T target) throws InterruptedException { WaitStrategy waitStrategy = new ProgressiveSleepWaitStrategy(); while (true) { PollResult result = reader.poll(target); if (result == PollResult.NO_NEW_MESSAGES) { waitStrategy.snooze(); } if (result == PollResult.HAD_SOME_MESSAGES) { waitStrategy.reset(); } if (result == PollResult.END_OF_STREAM) { return; } if (Thread.interrupted()) { throw new InterruptedException(); } } }  static void decodeAll(IpcReader<T> reader, T target);  }