/** * Sets up the NGServer internals * * @param addr the InetAddress to bind to * @param port the port on which to listen * @param sessionPoolSize the max number of idle sessions allowed by the * pool */ private void init(InetAddress addr, int port, int sessionPoolSize) { this.addr = addr; this.port = port; this.aliasManager = new AliasManager(); allNailStats = new java.util.HashMap(); // allow a maximum of 10 idle threads. probably too high a number // and definitely should be configurable in the future sessionPool = new NGSessionPool(this, sessionPoolSize); }
/** * Shuts down the pool. Running nails are allowed to finish. */ void shutdown() { done = true; synchronized(lock) { while (poolEntries > 0) { take().shutdown(); } } }
sessionPool.shutdown();
sessionPool.give(this); socket = nextSocket();
sessionOnDeck = sessionPool.take(); Socket socket = serversocket.accept(); sessionOnDeck.run(socket);