IoFuture<Connection> getConnection(final EndpointImpl endpoint, final ConnectionKey key, final AuthenticationConfiguration authenticationConfiguration, boolean doConnect) { final FutureResult<Connection> future = connections.get(authenticationConfiguration); if (future != null) { return future.getIoFuture(); } if (! doConnect) { return null; } // add a new unshared connection State oldState; synchronized (ConnectionInfo.this) { oldState = ConnectionInfo.this.state; if (oldState == this) { final IoFuture<Connection> attempt = endpoint.connect(key.getRealUri(), null, connectOptions, key.getSslContext(), authenticationConfiguration); Map<AuthenticationConfiguration, FutureResult<Connection>> newConnections = new HashMap<>(connections); final FutureResult<Connection> futureResult = new FutureResult<>(); splice(futureResult, attempt, authenticationConfiguration); newConnections.put(authenticationConfiguration, futureResult); return attempt; } } // try again :( return RETRY; }
final MaybeShared maybeShared = new MaybeShared(authenticationConfiguration, attempt); final FutureResult<Connection> futureResult = new FutureResult<>(); splice(futureResult, attempt, authenticationConfiguration); attempt.addNotifier(new IoFuture.HandlingNotifier<Connection, Void>() { public void handleCancelled(final Void attachment) {
IoFuture<Connection> getConnection(final EndpointImpl endpoint, final ConnectionKey key, final AuthenticationConfiguration authenticationConfiguration, boolean doConnect) { final FutureResult<Connection> future = connections.get(authenticationConfiguration); if (future != null) { return future.getIoFuture(); } if (! doConnect) { return null; } // add a new unshared connection State oldState; synchronized (ConnectionInfo.this) { oldState = ConnectionInfo.this.state; if (oldState == this) { final IoFuture<Connection> attempt = endpoint.connect(key.getRealUri(), null, connectOptions, key.getSslContext(), authenticationConfiguration); Map<AuthenticationConfiguration, FutureResult<Connection>> newConnections = new HashMap<>(connections); final FutureResult<Connection> futureResult = new FutureResult<>(); splice(futureResult, attempt, authenticationConfiguration); newConnections.put(authenticationConfiguration, futureResult); return attempt; } } // try again :( return RETRY; }
final MaybeShared maybeShared = new MaybeShared(authenticationConfiguration, attempt); final FutureResult<Connection> futureResult = new FutureResult<>(); splice(futureResult, attempt, authenticationConfiguration); attempt.addNotifier(new IoFuture.HandlingNotifier<Connection, Void>() { public void handleCancelled(final Void attachment) {