/** * For unit-tests. Blocks until the node is initialized. * * @throws InterruptedException for unexpected interrupt */ public void waitReady() throws InterruptedException { eventReady.await(); }
/** * Wait until the event is fired. If it is already fired, returns immediately the result passed to the {@link * #fire(Object)} call. Same as {@link #await()} * * @return the result passed to the {@link #fire(Object)} * * @throws InterruptedException */ @Deprecated public T waitFired() throws InterruptedException { return await(); }
/** * Wait until the event is fired. If it is already fired, returns immediately the result passed to the {@link * #fire(Object)} call. * * @return the result passed to the {@link #fire(Object)} * * @throws InterruptedException */ public T await() throws InterruptedException { try { return await(0); } catch (TimeoutException e) { throw new RuntimeException("impossible: timeout can't be expired with 0 wait time"); } }
/** * If the parcel is being processing, block until the parcel been processed (been processed payment and payload contracts). * * @param parcelId parcel to wait for * @param millisToWait is time to wait in milliseconds * @throws TimeoutException for timeout * @throws InterruptedException for unexpected interrupt */ public void waitParcel(HashId parcelId, long millisToWait) throws TimeoutException, InterruptedException { Object x = null; // first check if item is processing as part of parcel x = checkParcelInternal(parcelId); if (x instanceof ParcelProcessor) { if(!((ParcelProcessor) x).isDone()) { ((ParcelProcessor) x).doneEvent.await(millisToWait); } } }
/** * If the item is being electing, block until the item been processed with the consensus. Otherwise * returns state immediately. * * @param itemId item to check or wait for * @param millisToWait is time to wait in milliseconds * @return item state * @throws TimeoutException for timeout * @throws InterruptedException for unexpected interrupt */ public ItemResult waitItem(HashId itemId, long millisToWait) throws TimeoutException, InterruptedException { Object x = null; x = checkItemInternal(itemId); if (x instanceof ItemProcessor) { if(!((ItemProcessor) x).isDone()) { ((ItemProcessor) x).doneEvent.await(millisToWait); } return ((ItemProcessor) x).getResult(); } else if (x instanceof ResyncProcessor) { return ((ResyncProcessor) x).getResult(); } return (ItemResult) x; }
ae.await(5000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(5000); } catch (TimeoutException e) { System.out.println("time is up");
boolean endWithFail = false; try { ae.await(1000); } catch (TimeoutException e) { endWithFail = true;
boolean endWithFail = false; try { ae.await(1000); } catch (TimeoutException e) { endWithFail = true;
ae.await(5000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(3000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(3000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(6000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(6000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(3000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(3000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(3000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(3000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(6000); } catch (TimeoutException e) { System.out.println("time is up");
ae.await(6000); } catch (TimeoutException e) { System.out.println("time is up");