Skip to content

Commit

Permalink
hoijui#50 store listener on a concurrent data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoav Luft committed Aug 18, 2020
1 parent 16cbedf commit 8545bd4
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
import com.illposed.osc.argument.handler.StringArgumentHandler;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.*;
import java.util.concurrent.*;

/**
* Dispatches {@link OSCPacket}s to registered listeners (<i>Method</i>s).
Expand All @@ -41,8 +35,8 @@ public class OSCPacketDispatcher implements OSCPacketListener {
private final ByteBuffer argumentTypesBuffer;
private final OSCSerializer serializer;
private final Charset typeTagsCharset;
private final List<SelectiveMessageListener> selectiveMessageListeners;
private final List<OSCBadDataListener> badDataListeners;
private final Queue<SelectiveMessageListener> selectiveMessageListeners;
private final Queue<OSCBadDataListener> badDataListeners;
private boolean metaInfoRequired;
/**
* Whether to disregard bundle time-stamps for dispatch-scheduling.
Expand Down Expand Up @@ -149,8 +143,8 @@ public OSCPacketDispatcher(
this.typeTagsCharset = (propertiesCharset == null)
? Charset.defaultCharset()
: propertiesCharset;
this.selectiveMessageListeners = new ArrayList<>();
this.badDataListeners = new ArrayList<>();
this.selectiveMessageListeners = new ConcurrentLinkedQueue<>();
this.badDataListeners = new ConcurrentLinkedQueue<>();
this.metaInfoRequired = false;
this.alwaysDispatchingImmediately = false;
this.dispatchScheduler = dispatchScheduler;
Expand Down

0 comments on commit 8545bd4

Please sign in to comment.