Skip to content
Snippets Groups Projects
Commit 2dc02e0f authored by Herwin van Welbergen's avatar Herwin van Welbergen
Browse files

- made listenerlist threadsafe

- fixed typo in ipaaca documentation
parent 91d611e3
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ import ipaaca.LocalMessageIU;
import ipaaca.OutputBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
......@@ -39,7 +40,7 @@ public class ComponentNotifier
private final ImmutableSet<String> sendCategories;
private final ImmutableSet<String> receiveCategories;
private final InputBuffer inBuffer;
private List<HandlerFunctor> handlers = new ArrayList<HandlerFunctor>();
private List<HandlerFunctor> handlers = Collections.synchronizedList(new ArrayList<HandlerFunctor>());
private volatile boolean isInitialized = false;
private final BlockingQueue<String> receiverQueue = new LinkedBlockingQueue<>();
......@@ -51,9 +52,12 @@ public class ComponentNotifier
if(iu.getPayload().get(NAME).equals(componentName))return; //don't re-notify self
String receivers[] = iu.getPayload().get(RECEIVE_CATEGORIES).split("\\s*,\\s*");
receiverQueue.addAll(ImmutableSet.copyOf(receivers));
for (HandlerFunctor h : handlers)
synchronized(handlers)
{
h.handle(iu, type, local);
for (HandlerFunctor h : handlers)
{
h.handle(iu, type, local);
}
}
if (iu.getPayload().get(STATE).equals("new"))
{
......
......@@ -1086,7 +1086,7 @@ class Buffer(object):
for_event_types -- a list of event types or None if handler should
be called for all event types
for_categories -- a list of category names or None if handler should
be called for all categoires
be called for all categories
"""
handler = IUEventHandler(handler_function=handler_function, for_event_types=for_event_types, for_categories=for_categories)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment