Pushes completion to this and b unless both done. Caller should first check that either result
or b.result is null.
16234
final void bipush(CompletableFuture<?> b, BiCompletion<?, ?, ?> c) {
    if (c != null) {
      while (result == null) {
        if (tryPushStack(c)) {
          if (b.result == null)
            b.unipush(new CoCompletion(c));
          else if (result != null)
            c.tryFire(SYNC);
          return;
        }
      }
      b.unipush(c);
    }
  }
986612
@Override
    public void complete(VirtualConnection vc) {

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "complete() called: vc=" + vc);
        }
        // The VC might be null if the channel was destroyed before the callback completes
        if (vc != null) {
            HttpInboundServiceContextImpl mySC = (HttpInboundServiceContextImpl) vc.getStateMap().get(CallbackIDs.CALLBACK_HTTPISC);
            mySC.finishSendError();
        }
    }
84682
private void checkDone() {
    if (doneHandler != null) {
      if (cause != null) {
        doneHandler.handle(new DefaultFutureResult<T>(cause));
      } else {
        if (count == required) {
          doneHandler.handle(new DefaultFutureResult<T>((T) null));
        }
      }
    }
  }
706017
protected ExecutionResult postExecute(ExecutionResult result) {
    if (isFailure(result)) {
      result = onFailure(result.with(false, false));
      callFailureListener(result);
    } else {
      result = result.with(true, true);
      onSuccess(result);
      callSuccessListener(result);
    }

    return result;
  }
1154271
private void waitForCompletion() {
        for (ListenableFuture<?> future : pendingTasks.values()) {
            try {
                future.get();
            } catch (InterruptedException | ExecutionException e) {
                LOG.error("[" + this + "] Error waiting for writes to complete: " + e.getMessage());
            }
        }
    }
208043
@Override
  boolean push(TraceMethod traceMethod) {
    boolean success;
    TracingContext currentTracingContext = getCurrentTracingContext();
    if (currentTracingContext != null && !currentTracingContext.isCorrupted()) {
      if (currentTracingContext.getMethodStack().size() >= STACK_SIZE) {
        currentTracingContext.setCorrupted(true);
        throw new ThreadMap.RuntimeException("Stacksize is exceeded.");
      }
      else {
        currentTracingContext.getMethodStack().push(traceMethod);
        success = true;
      }
    }
    else
      success = false;
    
    return success;
  }
750282
public static Object delayedNull(CompletionStage<Void> stage) {
      // If stage was null - meant we didn't notify or if it already completed, no reason to create a stage instance
      if (stage == null || CompletionStages.isCompletedSuccessfully(stage)) {
         return null;
      } else {
         return asyncValue(stage);
      }
   }
1271465
@Override
    public void afterCompletion(int status)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "afterCompletion : " + status + " : " + this);

        closeTxEntityManager(ivEm, true);

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "afterCompletion");
    }
539000
private IGPSObject waitForResult() {
		synchronized (this.asyncWaitMutex) {
			if (this.asyncResult == null) {
				try {
					this.asyncWaitMutex.wait(1000);
				} catch (final InterruptedException e) {
					GPSdEndpoint.LOG.info("Interrupted while waiting for result", e);
				}
			}
			final IGPSObject result = this.asyncResult;
			this.asyncResult = null;
			return result;
		}
	}
433620
@Override
    public synchronized void complete() {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINEST)) {
            logger.entering(CLASS_NAME, "complete",this);
        }

        if (!lockHeldByDifferentThread())
        {
            //We can't call this or WebContainer won't know to run the complete runnable which kicks off the async listeners
            //        WebContainerRequestState.getInstance(true).setAsyncMode(false);

            if (!completePending){
                //Move this inside of if block because it complete is called
                //after a previous complete, you can get a NPE because the
                //request may have already been cleaned up. If complete is not
                //pending, then it shouldn't have been cleaned up.
                
                if (com.ibm.ws.webcontainer.osgi.WebContainer.getServletContainerSpecLevel() > 31) {
                    //setAsyncStarted(false) upon exit service()
                    WebContainerRequestState reqState = WebContainerRequestState.getInstance(true);
                    reqState.setAttribute("webcontainer.resetAsyncStartedOnExit", "true"); 
                }
                else {
                    iExtendedRequest.setAsyncStarted(false);
                }

                createNewAsyncServletReeentrantLock();

                cancelAsyncTimer();

                completeRunnable = new CompleteRunnable(iExtendedRequest,this);
                completePending = true;
                if (!dispatching){
                    executeNextRunnable();
                }

            }
        } else {
            if (WCCustomProperties.THROW_EXCEPTION_WHEN_UNABLE_TO_COMPLETE_OR_DISPATCH) {
                throw new IllegalStateException(nls.getString("AsyncContext.lock.already.held", "Unable to obtain the lock.  Error processing has already been invoked by another thread."));
            }
        }

        dispatchURI = null;

        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINEST)) {
            logger.exiting(CLASS_NAME, "complete",this);
        }

    }
999602
public synchronized final void completed(@CheckForNull Throwable error) {
        if (executor!=null) {
            executor.completedAsynchronous(error);
        } else {
            result = error == null ? NULL : error;
        }
    }
41359
public void setSuccess(V result) {
        if (this.isCancelled()) {
            this.releaseIfNeed(result);
        }
        if (setSuccess0(result)) {
            notifyListeners();
            return;
        }
        throw new IllegalStateException("complete already: " + this);
    }
522298
protected <T> TypedResult<T> handleMissingResult() {
		// check if the monitoring thread is still there
		// we need to wait until we know what is going on
		if (monitoringThread.isAlive()) {
			return TypedResult.empty();
		}
		// the job finished with an exception
		else if (executionException != null) {
			throw executionException;
		}
		// we assume that a bounded job finished
		else {
			return TypedResult.endOfStream();
		}
	}
609402
private void checkForCompletion() {
        final String methodName = "checkForCompletion(): ";
        // mark the list complete if that was the last awaited key
        if (actualIndices.isEmpty()) {
            if (tc.isDebugEnabled())
                Tr.debug(tc, methodName + "setting state=COMPLETE");
            state = failedKeys == null
                            ? COMPLETE
                            : COMPLETE_WITH_FAILURES; // state change must be last action
        }
    }
1004388
public <T> Future<Boolean> push(String k, T value) {
    Future<Boolean> rv = null;
    while (rv == null) {
      try {
        rv = client.set(k, expiration, value);
      } catch (IllegalStateException ex) {
        // Need to slow down a bit when we start getting rejections.
        try {
          if (rv != null) {
            rv.get(250, TimeUnit.MILLISECONDS);
          } else {
            Thread.sleep(250);
          }
        } catch (InterruptedException ie) {
          Thread.currentThread().interrupt();
        } catch (Exception e2) {
          // Ignore exceptions here. We're just trying to slow
          // down input.
        }
      }

    }
    return rv;
  }
1148631
private void addResult(ValidationResult result) {
		if (result == null || result.count() == 0) {
			return;
		}
		this.results.add(result);
	}
1348690
public void complete( T result, Object error ) {
        synchronized (this) {
            if ( isComplete ) {
                throw new RuntimeException("Promise can be completed only once");
            }
            this.result = result;
            this.error = error;
            isComplete = true;
            tryFire();
        }
    }