runelite-client/chat: Be more thread safe
This commit is contained in:
@@ -24,8 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.chat;
|
package net.runelite.client.chat;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiPredicate;
|
import java.util.function.BiPredicate;
|
||||||
@@ -43,7 +43,7 @@ import net.runelite.client.events.PrivateMessageInput;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class ChatCommandManager implements ChatboxInputListener
|
public class ChatCommandManager implements ChatboxInputListener
|
||||||
{
|
{
|
||||||
private final Map<String, ChatCommand> commands = new HashMap<>();
|
private final Map<String, ChatCommand> commands = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final ScheduledExecutorService scheduledExecutorService;
|
private final ScheduledExecutorService scheduledExecutorService;
|
||||||
|
|||||||
@@ -556,16 +556,9 @@ public class ChatMessageManager
|
|||||||
|
|
||||||
public void process()
|
public void process()
|
||||||
{
|
{
|
||||||
if (!queuedMessages.isEmpty())
|
for (QueuedMessage msg; (msg = queuedMessages.poll()) != null; )
|
||||||
{
|
{
|
||||||
try
|
add(msg);
|
||||||
{
|
|
||||||
queuedMessages.forEach(this::add);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
queuedMessages.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.chat;
|
package net.runelite.client.chat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -55,7 +55,7 @@ public class CommandManager
|
|||||||
private final ClientThread clientThread;
|
private final ClientThread clientThread;
|
||||||
private boolean sending;
|
private boolean sending;
|
||||||
|
|
||||||
private final List<ChatboxInputListener> chatboxInputListenerList = new ArrayList<>();
|
private final List<ChatboxInputListener> chatboxInputListenerList = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CommandManager(Client client, EventBus eventBus, ClientThread clientThread)
|
private CommandManager(Client client, EventBus eventBus, ClientThread clientThread)
|
||||||
|
|||||||
Reference in New Issue
Block a user