Make the variable's purpose a little more obvious

(shendaras)
This commit is contained in:
shendaras
2004-04-10 06:47:15 +00:00
committed by zzz
parent c47bfce010
commit 400a35de1d
2 changed files with 16 additions and 16 deletions

View File

@ -41,12 +41,12 @@ public class HTTPTunnel {
* *
* @param initialManagers a list of socket managers to use * @param initialManagers a list of socket managers to use
* @param maxManagers how many managers to have in the cache * @param maxManagers how many managers to have in the cache
* @param mcDonaldsMode whether to throw away a manager after use * @param shouldThrowAwayManagers whether to throw away a manager after use
* @param listenPort which port to listen on * @param listenPort which port to listen on
*/ */
public HTTPTunnel(I2PSocketManager[] initialManagers, int maxManagers, public HTTPTunnel(I2PSocketManager[] initialManagers, int maxManagers,
boolean mcDonaldsMode, int listenPort) { boolean shouldThrowAwayManagers, int listenPort) {
this(initialManagers, maxManagers, mcDonaldsMode, listenPort, this(initialManagers, maxManagers, shouldThrowAwayManagers, listenPort,
"127.0.0.1", 7654); "127.0.0.1", 7654);
} }
@ -55,17 +55,17 @@ public class HTTPTunnel {
* *
* @param initialManagers a list of socket managers to use * @param initialManagers a list of socket managers to use
* @param maxManagers how many managers to have in the cache * @param maxManagers how many managers to have in the cache
* @param mcDonaldsMode whether to throw away a manager after use * @param shouldThrowAwayManagers whether to throw away a manager after use
* @param listenPort which port to listen on * @param listenPort which port to listen on
* @param i2cpAddress the I2CP address * @param i2cpAddress the I2CP address
* @param i2cpPort the I2CP port * @param i2cpPort the I2CP port
*/ */
public HTTPTunnel(I2PSocketManager[] initialManagers, int maxManagers, public HTTPTunnel(I2PSocketManager[] initialManagers, int maxManagers,
boolean mcDonaldsMode, int listenPort, boolean shouldThrowAwayManagers, int listenPort,
String i2cpAddress, int i2cpPort) { String i2cpAddress, int i2cpPort) {
SocketManagerProducer smp = SocketManagerProducer smp =
new SocketManagerProducer(initialManagers, maxManagers, new SocketManagerProducer(initialManagers, maxManagers,
mcDonaldsMode, i2cpAddress, i2cpPort); shouldThrowAwayManagers, i2cpAddress, i2cpPort);
new HTTPListener(smp, listenPort, "127.0.0.1"); new HTTPListener(smp, listenPort, "127.0.0.1");
} }
@ -77,7 +77,7 @@ public class HTTPTunnel {
public static void main(String[] args) { public static void main(String[] args) {
String host = "127.0.0.1"; String host = "127.0.0.1";
int port = 7654, max = 1; int port = 7654, max = 1;
boolean mc = false; boolean throwAwayManagers = false;
if (args.length >1) { if (args.length >1) {
if (args.length == 4) { if (args.length == 4) {
host = args[2]; host = args[2];
@ -93,9 +93,9 @@ public class HTTPTunnel {
max = 1; max = 1;
} else if (max <0) { } else if (max <0) {
max = -max; max = -max;
mc = true; throwAwayManagers = true;
} }
new HTTPTunnel(null, max, mc, Integer.parseInt(args[0]), host, port); new HTTPTunnel(null, max, throwAwayManagers, Integer.parseInt(args[0]), host, port);
} }
private static void showInfo() { private static void showInfo() {

View File

@ -14,31 +14,31 @@ public class SocketManagerProducer extends Thread {
private int port; private int port;
private String host; private String host;
private int maxManagers; private int maxManagers;
private boolean mcDonalds; private boolean shouldThrowAwayManagers;
/** /**
* Public constructor creating a SocketManagerProducer * Public constructor creating a SocketManagerProducer
* @param initialManagers a list of socket managers to use * @param initialManagers a list of socket managers to use
* @param maxManagers how many managers to have in the cache * @param maxManagers how many managers to have in the cache
* @param mcDonaldsMode whether to throw away a manager after use * @param shouldThrowAwayManagers whether to throw away a manager after use
* @param host which host to listen on * @param host which host to listen on
* @param port which port to listen on * @param port which port to listen on
*/ */
public SocketManagerProducer(I2PSocketManager[] initialManagers, public SocketManagerProducer(I2PSocketManager[] initialManagers,
int maxManagers, int maxManagers,
boolean mcDonaldsMode, boolean shouldThrowAwayManagers,
String host, int port) { String host, int port) {
if (maxManagers < 1) { if (maxManagers < 1) {
throw new IllegalArgumentException("maxManagers < 1"); throw new IllegalArgumentException("maxManagers < 1");
} }
this.host=host; this.host=host;
this.port=port; this.port=port;
mcDonalds=mcDonaldsMode; this.shouldThrowAwayManagers=shouldThrowAwayManagers;
if (initialManagers != null) { if (initialManagers != null) {
myManagers.addAll(Arrays.asList(initialManagers)); myManagers.addAll(Arrays.asList(initialManagers));
} }
this.maxManagers=maxManagers; this.maxManagers=maxManagers;
mcDonalds=mcDonaldsMode; this.shouldThrowAwayManagers=shouldThrowAwayManagers;
setDaemon(true); setDaemon(true);
start(); start();
} }
@ -52,7 +52,7 @@ public class SocketManagerProducer extends Thread {
synchronized(this) { synchronized(this) {
// without mcDonalds mode, we most probably need no // without mcDonalds mode, we most probably need no
// new managers. // new managers.
while (!mcDonalds && myManagers.size() == maxManagers) { while (!shouldThrowAwayManagers && myManagers.size() == maxManagers) {
myWait(); myWait();
} }
} }
@ -102,7 +102,7 @@ public class SocketManagerProducer extends Thread {
} }
int which = (int)(Math.random()*myManagers.size()); int which = (int)(Math.random()*myManagers.size());
I2PSocketManager result = (I2PSocketManager) myManagers.get(which); I2PSocketManager result = (I2PSocketManager) myManagers.get(which);
if (mcDonalds) { if (shouldThrowAwayManagers) {
myManagers.remove(which); myManagers.remove(which);
notifyAll(); notifyAll();
} }