public void connectLater(Connection c) { if ( ! connectQueue.enqueue(c)) { parent.addConnection(c); } }
private void run() { try { while (true) { Connection conn = (Connection) connectQueue.dequeue(); parent.addConnection(conn.connect()); } } catch (EndOfQueueException e) {} synchronized (this) { done = true; notifyAll(); while (!exit) { try { wait(); } catch (InterruptedException x) {} } } }
private void run() { while (serverChannel.isOpen()) { try { parent.addConnection(new Connection(parent, owner, serverChannel.accept())); parent.sync(); } catch (ClosedChannelException ignore) { } catch (Exception e) { log.log(Level.WARNING, "Error accepting connection", e); } } while (true) { try { shutdownGate.await(); return; } catch (InterruptedException ignore) {} } }
/** * Connect to the given address. This method is called by a {@link * Supervisor} object. * * @return the new connection * @param owner the one calling this method * @param spec the address to connect to * @param context application context for the new connection * @param sync perform a synchronous connect in the calling thread * if this flag is set */ Connection connect(Supervisor owner, Spec spec, Object context, boolean sync) { Connection conn = new Connection(this, owner, spec, context); if (sync) { addConnection(conn.connect()); } else { connector.connectLater(conn); } return conn; }