/** * @return Futures size. */ private synchronized int futuresCount() { return futuresCountNoLock(); }
/** * Returns future at the specified position in this list. * * @param idx - index index of the element to return * @return Future. */ @SuppressWarnings("unchecked") protected final IgniteInternalFuture<T> future(int idx) { assert Thread.holdsLock(this); assert futs != null && idx >= 0 && idx < futuresCountNoLock(); if (futs instanceof IgniteInternalFuture) { assert idx == 0; return (IgniteInternalFuture<T>)futs; } else return ((List<IgniteInternalFuture>)futs).get(idx); }
/** * Checks if there are pending futures. This is not the same as * {@link #isDone()} because child classes may override {@link #onDone(Object, Throwable)} * call and delay completion. * * @return {@code True} if there are pending futures. */ protected final boolean hasPending() { synchronized (this) { int size = futuresCountNoLock(); // Avoid iterator creation and collection copy. for (int i = 0; i < size; i++) { IgniteInternalFuture<T> fut = future(i); if (!fut.isDone()) return true; } } return false; }
/** * @return Futures size. */ private synchronized int futuresCount() { return futuresCountNoLock(); }
/** * Returns future at the specified position in this list. * * @param idx - index index of the element to return * @return Future. */ @SuppressWarnings("unchecked") protected final IgniteInternalFuture<T> future(int idx) { assert Thread.holdsLock(this); assert futs != null && idx >= 0 && idx < futuresCountNoLock(); if (futs instanceof IgniteInternalFuture) { assert idx == 0; return (IgniteInternalFuture<T>)futs; } else return ((List<IgniteInternalFuture>)futs).get(idx); }
/** * Checks if there are pending futures. This is not the same as * {@link #isDone()} because child classes may override {@link #onDone(Object, Throwable)} * call and delay completion. * * @return {@code True} if there are pending futures. */ @SuppressWarnings("ForLoopReplaceableByForEach") protected final boolean hasPending() { synchronized (this) { int size = futuresCountNoLock(); // Avoid iterator creation and collection copy. for (int i = 0; i < size; i++) { IgniteInternalFuture<T> fut = future(i); if (!fut.isDone()) return true; } } return false; }