/** * Equivalent to {@code getRoot().quietlyComplete()}. */ public final void quietlyCompleteRoot() { for (CountedCompleter<?> a = this, p;;) { if ((p = a.completer) == null) { a.quietlyComplete(); return; } a = p; } }
/** * Equivalent to {@link #tryComplete} but does not invoke {@link * #onCompletion} along the completion path: If the pending count * is nonzero, decrements the count; otherwise, similarly tries to * complete this task's completer, if one exists, else marks this * task as complete. This method may be useful in cases where * {@code onCompletion} should not, or need not, be invoked for * each completer in a computation. */ public final void propagateCompletion() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * If this task does not have a completer, invokes {@link * ForkJoinTask#quietlyComplete} and returns {@code null}. Or, if * the completer's pending count is non-zero, decrements that * pending count and returns {@code null}. Otherwise, returns the * completer. This method can be used as part of a completion * traversal loop for homogeneous task hierarchies: * * <pre> {@code * for (CountedCompleter<?> c = firstComplete(); * c != null; * c = c.nextComplete()) { * // ... process c ... * }}</pre> * * @return the completer, or {@code null} if none */ public final CountedCompleter<?> nextComplete() { CountedCompleter<?> p; if ((p = completer) != null) return p.firstComplete(); else { quietlyComplete(); return null; } }
/** * If the pending count is nonzero, decrements the count; * otherwise invokes {@link #onCompletion} and then similarly * tries to complete this task's completer, if one exists, * else marks this task as complete. */ public final void tryComplete() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { a.onCompletion(s); if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * Regardless of pending count, invokes {@link #onCompletion}, * marks this task as complete and further triggers {@link * #tryComplete} on this task's completer, if one exists. The * given rawResult is used as an argument to {@link #setRawResult} * before invoking {@link #onCompletion} or marking this task as * complete; its value is meaningful only for classes overriding * {@code setRawResult}. * * <p>This method may be useful when forcing completion as soon as * any one (versus all) of several subtask results are obtained. * However, in the common (and recommended) case in which {@code * setRawResult} is not overridden, this effect can be obtained * more simply using {@code quietlyCompleteRoot();}. * * @param rawResult the raw result */ public void complete(T rawResult) { CountedCompleter<?> p; setRawResult(rawResult); onCompletion(this); quietlyComplete(); if ((p = completer) != null) p.tryComplete(); }
/** * Equivalent to {@code getRoot().quietlyComplete()}. */ public final void quietlyCompleteRoot() { for (CountedCompleter<?> a = this, p;;) { if ((p = a.completer) == null) { a.quietlyComplete(); return; } a = p; } }
/** * Equivalent to {@code getRoot().quietlyComplete()}. */ public final void quietlyCompleteRoot() { for (CountedCompleter<?> a = this, p;;) { if ((p = a.completer) == null) { a.quietlyComplete(); return; } a = p; } }
/** * Equivalent to {@code getRoot().quietlyComplete()}. */ public final void quietlyCompleteRoot() { for (CountedCompleter<?> a = this, p;;) { if ((p = a.completer) == null) { a.quietlyComplete(); return; } a = p; } }
/** * Equivalent to {@code getRoot().quietlyComplete()}. */ public final void quietlyCompleteRoot() { for (CountedCompleter<?> a = this, p;;) { if ((p = a.completer) == null) { a.quietlyComplete(); return; } a = p; } }
/** * Equivalent to {@code getRoot().quietlyComplete()}. */ public final void quietlyCompleteRoot() { for (CountedCompleter<?> a = this, p;;) { if ((p = a.completer) == null) { a.quietlyComplete(); return; } a = p; } }
/** * Equivalent to {@code getRoot().quietlyComplete()}. */ public final void quietlyCompleteRoot() { for (CountedCompleter<?> a = this, p;;) { if ((p = a.completer) == null) { a.quietlyComplete(); return; } a = p; } }
/** * Equivalent to {@link #tryComplete} but does not invoke {@link * #onCompletion} along the completion path: If the pending count * is nonzero, decrements the count; otherwise, similarly tries to * complete this task's completer, if one exists, else marks this * task as complete. This method may be useful in cases where * {@code onCompletion} should not, or need not, be invoked for * each completer in a computation. */ public final void propagateCompletion() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * Equivalent to {@link #tryComplete} but does not invoke {@link * #onCompletion} along the completion path: If the pending count * is nonzero, decrements the count; otherwise, similarly tries to * complete this task's completer, if one exists, else marks this * task as complete. This method may be useful in cases where * {@code onCompletion} should not, or need not, be invoked for * each completer in a computation. */ public final void propagateCompletion() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * If the pending count is nonzero, decrements the count; * otherwise invokes {@link #onCompletion} and then similarly * tries to complete this task's completer, if one exists, * else marks this task as complete. */ public final void tryComplete() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { a.onCompletion(s); if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * If the pending count is nonzero, decrements the count; * otherwise invokes {@link #onCompletion} and then similarly * tries to complete this task's completer, if one exists, * else marks this task as complete. */ public final void tryComplete() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { a.onCompletion(s); if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * If the pending count is nonzero, decrements the count; * otherwise invokes {@link #onCompletion} and then similarly * tries to complete this task's completer, if one exists, * else marks this task as complete. */ public final void tryComplete() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { a.onCompletion(s); if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * If the pending count is nonzero, decrements the count; * otherwise invokes {@link #onCompletion} and then similarly * tries to complete this task's completer, if one exists, * else marks this task as complete. */ public final void tryComplete() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { a.onCompletion(s); if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * If the pending count is nonzero, decrements the count; * otherwise invokes {@link #onCompletion} and then similarly * tries to complete this task's completer, if one exists, * else marks this task as complete. */ public final void tryComplete() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { a.onCompletion(s); if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * If the pending count is nonzero, decrements the count; * otherwise invokes {@link #onCompletion} and then similarly * tries to complete this task's completer, if one exists, * else marks this task as complete. */ public final void tryComplete() { CountedCompleter<?> a = this, s = a; for (int c;;) { if ((c = a.pending) == 0) { a.onCompletion(s); if ((a = (s = a).completer) == null) { s.quietlyComplete(); return; } } else if (U.compareAndSwapInt(a, PENDING, c, c - 1)) return; } }
/** * Regardless of pending count, invokes {@link #onCompletion}, * marks this task as complete and further triggers {@link * #tryComplete} on this task's completer, if one exists. The * given rawResult is used as an argument to {@link #setRawResult} * before invoking {@link #onCompletion} or marking this task as * complete; its value is meaningful only for classes overriding * {@code setRawResult}. * * <p>This method may be useful when forcing completion as soon as * any one (versus all) of several subtask results are obtained. * However, in the common (and recommended) case in which {@code * setRawResult} is not overridden, this effect can be obtained * more simply using {@code quietlyCompleteRoot();}. * * @param rawResult the raw result */ public void complete(T rawResult) { CountedCompleter<?> p; setRawResult(rawResult); onCompletion(this); quietlyComplete(); if ((p = completer) != null) p.tryComplete(); }