private Result send(Function<Long, Response> responses, DocumentOperationParameters parameters) {
        Result.ResultType resultType = result.get();
        if (resultType != SUCCESS)
            return new Result(resultType, Result.toError(resultType));

        ResponseHandler responseHandler = parameters.responseHandler().orElse(this::addResponse);
        long req = requestId.incrementAndGet();
        Phaser synchronizer = phaser.get();
        if (synchronizer == null)
            responseHandler.handleResponse(responses.apply(req));
        else {
            synchronizer.register();
            executor.execute(() -> {
                try {
                    synchronizer.arriveAndAwaitAdvance();
                    responseHandler.handleResponse(responses.apply(req));
                }
                finally {
                    synchronizer.awaitAdvance(synchronizer.arriveAndDeregister());
                }
            });
        }
        return new Result(req);
    }
Sets the result type returned on subsequence operations against this. Only SUCCESS will cause Responses to appear.
documentapi/src/main/java/com/yahoo/documentapi/local/LocalAsyncSession.java