@Test public void testAwait() { final AbstractBackgroundAction action = new AbstractBackgroundAction() { @Override public Object run() throws BackgroundException { throw new BackgroundException(new RuntimeException("f")); } }; try { action.call(); fail(); } catch(BackgroundException e) { } new BackgroundActionPauser(new BackgroundActionPauser.Callback() { @Override public void validate() throws ConnectionCanceledException { if(action.isCanceled()) { throw new ConnectionCanceledException(); } } @Override public void progress(final Integer delay) { } }).await(); }
public void await() { if(0 == delay) { log.info("No pause between retry"); return; } final Timer wakeup = new Timer(); final CyclicBarrier wait = new CyclicBarrier(2); wakeup.scheduleAtFixedRate(new PauserTimerTask(wait), 0, 1000); try { wait.await(); } catch(InterruptedException | BrokenBarrierException e) { log.error(e.getMessage(), e); } }
BackgroundActionPauser { public void await() { if(0 == delay) { log.info("No pause between retry"); return; } final Timer wakeup = new Timer(); final CyclicBarrier wait = new CyclicBarrier(2); wakeup.scheduleAtFixedRate(new PauserTimerTask(wait), 0, 1000); try { wait.await(); } catch(InterruptedException | BrokenBarrierException e) { log.error(e.getMessage(), e); } } }
BackgroundActionPauser { public void await() { if(0 == delay) { log.info("No pause between retry"); return; } final Timer wakeup = new Timer(); final CyclicBarrier wait = new CyclicBarrier(2); wakeup.scheduleAtFixedRate(new PauserTimerTask(wait), 0, 1000); try { wait.await(); } catch(InterruptedException | BrokenBarrierException e) { log.error(e.getMessage(), e); } } BackgroundActionPauser(final Callback callback);  BackgroundActionPauser(final Callback callback, final Integer delay); }
BackgroundActionPauser { public void await() { if(0 == delay) { log.info("No pause between retry"); return; } final Timer wakeup = new Timer(); final CyclicBarrier wait = new CyclicBarrier(2); wakeup.scheduleAtFixedRate(new PauserTimerTask(wait), 0, 1000); try { wait.await(); } catch(InterruptedException | BrokenBarrierException e) { log.error(e.getMessage(), e); } } BackgroundActionPauser(final Callback callback);  BackgroundActionPauser(final Callback callback, final Integer delay); void await(); }
BackgroundActionPauser { public void await() { if(0 == delay) { log.info("No pause between retry"); return; } final Timer wakeup = new Timer(); final CyclicBarrier wait = new CyclicBarrier(2); wakeup.scheduleAtFixedRate(new PauserTimerTask(wait), 0, 1000); try { wait.await(); } catch(InterruptedException | BrokenBarrierException e) { log.error(e.getMessage(), e); } } BackgroundActionPauser(final Callback callback);  BackgroundActionPauser(final Callback callback, final Integer delay); void await();  }