mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-31 19:57:06 +01:00
Use AtomicInteger rather than synchronization
This commit is contained in:
parent
373c0249bc
commit
35d172225f
1 changed files with 3 additions and 4 deletions
|
@ -59,6 +59,7 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class RelayService extends XWService
|
public class RelayService extends XWService
|
||||||
implements NetStateCache.StateChangedIf {
|
implements NetStateCache.StateChangedIf {
|
||||||
|
@ -98,7 +99,7 @@ public class RelayService extends XWService
|
||||||
private static final String BINBUFFER = "BINBUFFER";
|
private static final String BINBUFFER = "BINBUFFER";
|
||||||
|
|
||||||
private static HashSet<Integer> s_packetsSent = new HashSet<Integer>();
|
private static HashSet<Integer> s_packetsSent = new HashSet<Integer>();
|
||||||
private static int s_nextPacketID = 1;
|
private static AtomicInteger s_nextPacketID = new AtomicInteger();
|
||||||
private static boolean s_gcmWorking = false;
|
private static boolean s_gcmWorking = false;
|
||||||
private static boolean s_registered = false;
|
private static boolean s_registered = false;
|
||||||
private static CommsAddrRec s_addr =
|
private static CommsAddrRec s_addr =
|
||||||
|
@ -1304,9 +1305,7 @@ public class RelayService extends XWService
|
||||||
{
|
{
|
||||||
int nextPacketID = 0;
|
int nextPacketID = 0;
|
||||||
if ( XWRelayReg.XWPDEV_ACK != cmd ) {
|
if ( XWRelayReg.XWPDEV_ACK != cmd ) {
|
||||||
synchronized( s_packetsSent ) {
|
nextPacketID = s_nextPacketID.incrementAndGet();
|
||||||
nextPacketID = ++s_nextPacketID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nextPacketID;
|
return nextPacketID;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue