Replaced several CopyOnWriteArrayList occurrences with ConcurrentHashMap.newKeySet().

This commit is contained in:
MobiusDevelopment
2019-08-07 01:57:06 +00:00
parent c3a6557797
commit 9048735b73
395 changed files with 1430 additions and 1315 deletions

View File

@@ -19,15 +19,15 @@ package org.l2jmobius.gameserver.communitybbs.Manager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.communitybbs.BB.Forum;
public class ForumsBBSManager extends BaseBBSManager
{
private final List<Forum> _table;
private final Collection<Forum> _table;
private int _lastid = 1;
public static ForumsBBSManager getInstance()
@@ -37,7 +37,7 @@ public class ForumsBBSManager extends BaseBBSManager
protected ForumsBBSManager()
{
_table = new CopyOnWriteArrayList<>();
_table = ConcurrentHashMap.newKeySet();
try (Connection con = DatabaseFactory.getConnection())
{

View File

@@ -20,6 +20,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -70,7 +71,7 @@ public class GrandBossManager
private Map<Integer, Integer> _bossStatus;
private List<BossZone> _zones;
private Collection<BossZone> _zones;
public static GrandBossManager getInstance()
{
@@ -89,7 +90,7 @@ public class GrandBossManager
private void init()
{
_zones = new CopyOnWriteArrayList<>();
_zones = ConcurrentHashMap.newKeySet();
_bosses = new ConcurrentHashMap<>();
_storedInfo = new ConcurrentHashMap<>();
_bossStatus = new ConcurrentHashMap<>();

View File

@@ -17,7 +17,9 @@
package org.l2jmobius.gameserver.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.instance.GrandBossInstance;
@@ -35,7 +37,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
*/
public class CommandChannel
{
private final List<Party> _parties;
private final Collection<Party> _parties;
private PlayerInstance _commandLeader = null;
private int _channelLvl;
@@ -46,7 +48,7 @@ public class CommandChannel
public CommandChannel(PlayerInstance leader)
{
_commandLeader = leader;
_parties = new ArrayList<>();
_parties = ConcurrentHashMap.newKeySet();
_parties.add(leader.getParty());
_channelLvl = leader.getParty().getLevel();
leader.getParty().setCommandChannel(this);
@@ -179,7 +181,7 @@ public class CommandChannel
/**
* @return list of Parties in Command Channel
*/
public List<Party> getPartys()
public Collection<Party> getParties()
{
return _parties;
}

View File

@@ -46,8 +46,8 @@ public class ExMultiPartyCommandChannelInfo extends GameServerPacket
writeD(0); // Channel loot
writeD(_channel.getMemberCount());
writeD(_channel.getPartys().size());
for (Party p : _channel.getPartys())
writeD(_channel.getParties().size());
for (Party p : _channel.getParties())
{
writeS(p.getLeader().getName());
writeD(p.getPartyLeaderOID());

View File

@@ -16,8 +16,8 @@
*/
package org.l2jmobius.gameserver.thread.daemons;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import org.l2jmobius.Config;
@@ -31,12 +31,12 @@ public class ItemsAutoDestroy
{
protected static final Logger LOGGER = Logger.getLogger(ItemsAutoDestroy.class.getName());
private static ItemsAutoDestroy _instance;
protected List<ItemInstance> _items = null;
protected Collection<ItemInstance> _items = null;
protected static long _sleep;
private ItemsAutoDestroy()
{
_items = new CopyOnWriteArrayList<>();
_items = ConcurrentHashMap.newKeySet();
_sleep = Config.AUTODESTROY_ITEM_AFTER * 1000;
if (_sleep == 0)
{

View File

@@ -29,11 +29,9 @@ import java.sql.ResultSet;
import java.util.Base64;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import javax.crypto.Cipher;
@@ -99,7 +97,7 @@ public class LoginController
private static final int LOGIN_TIMEOUT = 60 * 1000;
/** Clients that are on the LS but arent assocated with a account yet */
protected List<LoginClient> _clients = new CopyOnWriteArrayList<>();
protected Collection<LoginClient> _clients = ConcurrentHashMap.newKeySet();
/** Authed Clients on LoginServer */
protected Map<String, LoginClient> _loginServerClients = new ConcurrentHashMap<>();