@Override public ListenableFuture<SocketAddress> openConnection(SocketAddress serverAddress, StreamConnection connection) { if (!isRunning()) throw new IllegalStateException(); // Create a new connection, give it a connection as an attachment try { SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); sc.connect(serverAddress); PendingConnect data = new PendingConnect(sc, connection, serverAddress); newConnectionChannels.offer(data); selector.wakeup(); return data.future; } catch (Throwable e) { return Futures.immediateFailedFuture(e); } }
@Override public ListenableFuture<SocketAddress> openConnection(SocketAddress serverAddress, StreamConnection connection) { if (!isRunning()) throw new IllegalStateException(); // Create a new connection, give it a connection as an attachment try { SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); sc.connect(serverAddress); PendingConnect data = new PendingConnect(sc, connection, serverAddress); newConnectionChannels.offer(data); selector.wakeup(); return data.future; } catch (Throwable e) { return Futures.immediateFailedFuture(e); } }
@Override public ListenableFuture<SocketAddress> openConnection(SocketAddress serverAddress, StreamConnection connection) { if (!isRunning()) throw new IllegalStateException(); // Create a new connection, give it a connection as an attachment try { SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); sc.connect(serverAddress); PendingConnect data = new PendingConnect(sc, connection, serverAddress); newConnectionChannels.offer(data); selector.wakeup(); return data.future; } catch (Throwable e) { return Futures.immediateFailedFuture(e); } }
@Override public ListenableFuture<SocketAddress> openConnection(SocketAddress serverAddress, StreamConnection connection) { if (!isRunning()) throw new IllegalStateException(); // Create a new connection, give it a connection as an attachment try { SocketChannel sc = SocketChannel.open(); sc.configureBlocking(false); sc.connect(serverAddress); PendingConnect data = new PendingConnect(sc, connection, serverAddress); newConnectionChannels.offer(data); selector.wakeup(); return data.future; } catch (Throwable e) { return Futures.immediateFailedFuture(e); } }
try { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (isRunning()) { PendingConnect conn; while ((conn = newConnectionChannels.poll()) != null) {
try { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (isRunning()) { PendingConnect conn; while ((conn = newConnectionChannels.poll()) != null) {
try { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (isRunning()) { PendingConnect conn; while ((conn = newConnectionChannels.poll()) != null) {
try { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (isRunning()) { PendingConnect conn; while ((conn = newConnectionChannels.poll()) != null) {