|
@@ -27,7 +27,7 @@ import com.dmdirc.DMDircMBassador;
|
27
|
27
|
import java.util.Collections;
|
28
|
28
|
import java.util.Map;
|
29
|
29
|
import java.util.Set;
|
30
|
|
-import java.util.concurrent.ConcurrentSkipListMap;
|
|
30
|
+import java.util.concurrent.ConcurrentHashMap;
|
31
|
31
|
|
32
|
32
|
import javax.inject.Inject;
|
33
|
33
|
import javax.inject.Singleton;
|
|
@@ -45,7 +45,7 @@ public class AutoCommandManager {
|
45
|
45
|
/** The factory to use to create handlers. */
|
46
|
46
|
private final AutoCommandHandlerFactory factory;
|
47
|
47
|
/** Known auto commands, mapped on to their handlers. */
|
48
|
|
- private final Map<AutoCommand, AutoCommandHandler> autoCommands = new ConcurrentSkipListMap<>();
|
|
48
|
+ private final Map<AutoCommand, AutoCommandHandler> autoCommands = new ConcurrentHashMap<>();
|
49
|
49
|
/** Whether the manager has been started or not. */
|
50
|
50
|
private boolean started;
|
51
|
51
|
|
|
@@ -56,7 +56,9 @@ public class AutoCommandManager {
|
56
|
56
|
* @param factory The factory to use to create handlers.
|
57
|
57
|
*/
|
58
|
58
|
@Inject
|
59
|
|
- public AutoCommandManager(final DMDircMBassador eventBus, final AutoCommandHandlerFactory factory) {
|
|
59
|
+ public AutoCommandManager(
|
|
60
|
+ final DMDircMBassador eventBus,
|
|
61
|
+ final AutoCommandHandlerFactory factory) {
|
60
|
62
|
this.eventBus = eventBus;
|
61
|
63
|
this.factory = factory;
|
62
|
64
|
}
|
|
@@ -77,7 +79,7 @@ public class AutoCommandManager {
|
77
|
79
|
public void stop() {
|
78
|
80
|
started = false;
|
79
|
81
|
for (AutoCommandHandler handler : autoCommands.values()) {
|
80
|
|
- eventBus.subscribe(handler);
|
|
82
|
+ eventBus.unsubscribe(handler);
|
81
|
83
|
}
|
82
|
84
|
}
|
83
|
85
|
|
|
@@ -107,7 +109,7 @@ public class AutoCommandManager {
|
107
|
109
|
final AutoCommandHandler handler = autoCommands.remove(autoCommand);
|
108
|
110
|
|
109
|
111
|
if (started) {
|
110
|
|
- eventBus.subscribe(handler);
|
|
112
|
+ eventBus.unsubscribe(handler);
|
111
|
113
|
}
|
112
|
114
|
}
|
113
|
115
|
|