Use concurrent hash map, where possible

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2018-10-11 12:10:39 -04:00
parent 7934ab7435
commit 67abd91f72
3 changed files with 7 additions and 4 deletions

View File

@ -75,7 +75,8 @@ public final class CommandParameters {
for (final String string : bools) {
booleanArguments.put(string, Boolean.FALSE);
}
stringArguments = new ConcurrentHashMap<>(strings.size());
// Cannot use concurrent because of the null values.
stringArguments = new HashMap<>(strings.size());
for (final String string : strings) {
stringArguments.put(string, null);
}

View File

@ -87,6 +87,7 @@ import net.bigeon.gclc.manager.ConsoleInput;
import net.bigeon.gclc.manager.EmptyInput;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/** An object to handle standardized command parameters.
*
@ -96,9 +97,9 @@ public final class ParametrizedCommandData {
/** The boolean parameters mandatory status. */
private final Set<String> boolParams = new HashSet<>();
/** The string parameters mandatory status. */
private final Map<String, Boolean> stringParams = new HashMap<>();
private final Map<String, Boolean> stringParams = new ConcurrentHashMap<>();
/** The parameters mandatory status. */
private final Map<String, Boolean> params = new HashMap<>();
private final Map<String, Boolean> params = new ConcurrentHashMap<>();
/** The restriction of provided parameters on execution to declared paramters in
* the status maps. */
private final boolean strict;

View File

@ -78,6 +78,7 @@ import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -165,7 +166,7 @@ public final class ReadingRunnable implements Runnable {
/** The waiting status for a message. */
private boolean waiting;
/** The blocker for a given message. */
private final Map<String, Object> messageBlocker = new HashMap<>();
private final Map<String, Object> messageBlocker = new ConcurrentHashMap<>();
/** The lock. */
private final Object messageBlockerLock = new Object();
/** The message being delivered. */