Permalink
Browse files

remove unneeded thread safety from EventSubscription

  • Loading branch information...
1 parent 3b5c48b commit 7cbde55b01337eb134cfa2418a243bd0c8cc1c27 @ryanbrainard ryanbrainard committed Jun 27, 2012
Showing with 3 additions and 7 deletions.
  1. +3 −7 src/main/java/com/herokuapp/directto/client/EventSubscription.java
@@ -1,10 +1,6 @@
package com.herokuapp.directto.client;
-import java.util.EnumSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.*;
/**
* @author Ryan Brainard
@@ -25,7 +21,7 @@
void handle(Event event);
}
- private final Map<Event, Set<Subscriber>> subscribers = new ConcurrentHashMap<Event, Set<Subscriber>>();
+ private final Map<Event, Set<Subscriber>> subscribers = new EnumMap<Event, Set<Subscriber>>(Event.class);
void announce(Event event) {
if (subscribers.containsKey(event)) {
@@ -42,7 +38,7 @@ public EventSubscription subscribe(Event event, Subscriber subscriber) {
public EventSubscription subscribe(EnumSet<Event> events, Subscriber subscriber) {
for (Event event : events) {
if (!subscribers.containsKey(event)) {
- subscribers.put(event, new CopyOnWriteArraySet<Subscriber>());
+ subscribers.put(event, new HashSet<Subscriber>());
}
subscribers.get(event).add(subscriber);
}

0 comments on commit 7cbde55

Please sign in to comment.