forked from I2P_Developers/i2p.i2p
more static atomics
This commit is contained in:
@ -25,6 +25,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.util.I2PAppThread;
|
||||
@ -44,8 +45,8 @@ class PeerConnectionOut implements Runnable
|
||||
// Contains Messages.
|
||||
private final List<Message> sendQueue = new ArrayList();
|
||||
|
||||
private static long __id = 0;
|
||||
private long _id;
|
||||
private static final AtomicLong __id = new AtomicLong();
|
||||
private final long _id;
|
||||
|
||||
long lastSent;
|
||||
|
||||
@ -53,7 +54,7 @@ class PeerConnectionOut implements Runnable
|
||||
{
|
||||
this.peer = peer;
|
||||
this.dout = dout;
|
||||
_id = ++__id;
|
||||
_id = __id.incrementAndGet();
|
||||
|
||||
lastSent = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
|
||||
private long totalSent;
|
||||
private long totalReceived;
|
||||
|
||||
private volatile long __forwarderId;
|
||||
private static final AtomicLong __forwarderId = new AtomicLong();
|
||||
|
||||
public I2PTunnelRunner(Socket s, I2PSocket i2ps, Object slock, byte[] initialI2PData,
|
||||
List<I2PSocket> sockList) {
|
||||
@ -98,7 +98,6 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("I2PTunnelRunner started");
|
||||
_runnerId = __runnerId.incrementAndGet();
|
||||
__forwarderId = i2ps.hashCode();
|
||||
setName("I2PTunnelRunner " + _runnerId);
|
||||
start();
|
||||
}
|
||||
@ -312,7 +311,7 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
|
||||
_toI2P = toI2P;
|
||||
direction = (toI2P ? "toI2P" : "fromI2P");
|
||||
_cache = ByteCache.getInstance(32, NETWORK_BUFFER_SIZE);
|
||||
setName("StreamForwarder " + _runnerId + "." + (++__forwarderId));
|
||||
setName("StreamForwarder " + _runnerId + '.' + __forwarderId.incrementAndGet());
|
||||
start();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
package net.i2p.i2ptunnel.socks;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.i2ptunnel.I2PTunnel;
|
||||
@ -30,7 +31,7 @@ import net.i2p.util.Log;
|
||||
*/
|
||||
public class I2PSOCKSIRCTunnel extends I2PSOCKSTunnel {
|
||||
|
||||
private static int __clientId = 0;
|
||||
private static final AtomicInteger __clientId = new AtomicInteger();
|
||||
|
||||
/** @param pkf private key file name or null for transient key */
|
||||
public I2PSOCKSIRCTunnel(int localPort, Logging l, boolean ownDest, EventDispatcher notifyThis, I2PTunnel tunnel, String pkf) {
|
||||
@ -50,11 +51,12 @@ public class I2PSOCKSIRCTunnel extends I2PSOCKSTunnel {
|
||||
Socket clientSock = serv.getClientSocket();
|
||||
I2PSocket destSock = serv.getDestinationI2PSocket(this);
|
||||
StringBuffer expectedPong = new StringBuffer();
|
||||
int id = __clientId.incrementAndGet();
|
||||
Thread in = new I2PAppThread(new IrcInboundFilter(clientSock, destSock, expectedPong, _log),
|
||||
"SOCKS IRC Client " + (++__clientId) + " in", true);
|
||||
"SOCKS IRC Client " + id + " in", true);
|
||||
in.start();
|
||||
Thread out = new I2PAppThread(new IrcOutboundFilter(clientSock, destSock, expectedPong, _log),
|
||||
"SOCKS IRC Client " + __clientId + " out", true);
|
||||
"SOCKS IRC Client " + id + " out", true);
|
||||
out.start();
|
||||
} catch (SOCKSException e) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
|
@ -3,6 +3,7 @@ package net.i2p.client;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.Destination;
|
||||
@ -31,11 +32,11 @@ class MessageState {
|
||||
private boolean _cancelled;
|
||||
private final long _created;
|
||||
|
||||
private static long __stateId = 0;
|
||||
private long _stateId;
|
||||
private static final AtomicLong __stateId = new AtomicLong();
|
||||
private final long _stateId;
|
||||
|
||||
public MessageState(I2PAppContext ctx, long nonce, String prefix) {
|
||||
_stateId = ++__stateId;
|
||||
_stateId = __stateId.incrementAndGet();
|
||||
_context = ctx;
|
||||
_log = ctx.logManager().getLog(MessageState.class);
|
||||
_nonce = nonce;
|
||||
|
@ -24,6 +24,7 @@ import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
@ -738,11 +739,12 @@ public class LogManager {
|
||||
_consoleBuffer.clear();
|
||||
}
|
||||
|
||||
private static int __id = 0;
|
||||
private static final AtomicInteger __id = new AtomicInteger();
|
||||
|
||||
private class ShutdownHook extends Thread {
|
||||
private int _id;
|
||||
private final int _id;
|
||||
public ShutdownHook() {
|
||||
_id = ++__id;
|
||||
_id = __id.incrementAndGet();
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.i2p.router.networkdb.kademlia;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.RouterInfo;
|
||||
import net.i2p.data.i2np.DatabaseSearchReplyMessage;
|
||||
@ -17,7 +19,7 @@ import net.i2p.util.Log;
|
||||
class SearchMessageSelector implements MessageSelector {
|
||||
private final Log _log;
|
||||
private final RouterContext _context;
|
||||
private static int __searchSelectorId = 0;
|
||||
private static final AtomicInteger __searchSelectorId = new AtomicInteger();
|
||||
private final Hash _peer;
|
||||
private boolean _found;
|
||||
private final int _id;
|
||||
@ -31,7 +33,7 @@ class SearchMessageSelector implements MessageSelector {
|
||||
_found = false;
|
||||
_exp = expiration;
|
||||
_state = state;
|
||||
_id = ++__searchSelectorId;
|
||||
_id = __searchSelectorId.incrementAndGet();
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("[" + _id + "] Created: " + toString());
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
@ -902,7 +903,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
||||
return "?";
|
||||
}
|
||||
|
||||
private static int __id = 0;
|
||||
private static final AtomicInteger __id = new AtomicInteger();
|
||||
|
||||
/**
|
||||
* postControlAction() can take many seconds, especially if it's failing,
|
||||
@ -925,7 +926,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Starting thread to forward " + portsToForwardNow.size() + " ports");
|
||||
Thread t = new Thread(new RegisterPortsThread(portsToForwardNow));
|
||||
t.setName("UPnP Port Opener " + (++__id));
|
||||
t.setName("UPnP Port Opener " + __id.incrementAndGet());
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
@ -967,7 +968,7 @@ class UPnP extends ControlPoint implements DeviceChangeListener, EventListener {
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("Starting thread to un-forward " + portsToForwardNow.size() + " ports");
|
||||
Thread t = new Thread(new UnregisterPortsThread(portsToForwardNow));
|
||||
t.setName("UPnP Port Closer " + (++__id));
|
||||
t.setName("UPnP Port Closer " + __id.incrementAndGet());
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
|
Reference in New Issue
Block a user