test_class.declarator: QUEUE_CAPACITY = 128
test_class.modifier: private static final
test_class.original_string: private static final int QUEUE_CAPACITY = 128;
test_class.type: int
test_class.var_name: QUEUE_CAPACITY
test_class.declarator: executorService
test_class.modifier: private
test_class.original_string: private ExecutorService executorService;
test_class.type: ExecutorService
test_class.var_name: executorService
test_class.declarator: lazyMessages
test_class.modifier: private
test_class.original_string: private MessageBlockingQueue<LazyMessage<std_msgs.Int32>> lazyMessages;
test_class.type: MessageBlockingQueue<LazyMessage<std_msgs.Int32>>
test_class.var_name: lazyMessages
test_class.declarator: messageFactory
test_class.modifier: private
test_class.original_string: private MessageFactory messageFactory;
test_class.type: MessageFactory
test_class.var_name: messageFactory
test_class.file: rosjava/nrosjava/src/test/java/org/ros/internal/transport/queue/MessageDispatcherTest.java
test_class.identifier: MessageDispatcherTest
test_case.body: @Test
    public void testMessageOrder() throws InterruptedException {
      int numberOfMessages = 100;
      final CountDownLatch latch = new CountDownLatch(numberOfMessages);
  
      MessageDispatcher<std_msgs.Int32> messageDispatcher =
          new MessageDispatcher<std_msgs.Int32>(lazyMessages, executorService);
      messageDispatcher.addListener(new MessageListener<std_msgs.Int32>() {
        private AtomicInteger count = new AtomicInteger();
  
        @Override
        public void onNewMessage(Int32 message) {
          if (this.count.compareAndSet(message.getData(), message.getData() + 1)) {
            latch.countDown();
          } else {
            fail(String.format("Expected message data not equal to actual data: %d != %d", count.get(), message.getData()));
          }
          try {
            // Sleeping allows the queue to fill up a bit by slowing down the
            // consumer.
            Thread.sleep(5);
          } catch (InterruptedException e) {
          }
        }
      }, QUEUE_CAPACITY);
      executorService.execute(messageDispatcher);
  
      for (int i = 0; i < numberOfMessages; i++) {
        final int count = i;
        std_msgs.Int32 message = messageFactory.newFromType(std_msgs.Int32._TYPE);
        message.setData(count);
        lazyMessages.put(new LazyMessage<std_msgs.Int32>(message));
      }
  
      assertTrue(latch.await(1, TimeUnit.SECONDS));
    }
test_case.class_method_signature: MessageDispatcherTest.testMessageOrder()
test_case.full_signature: @Test public void testMessageOrder()
test_case.identifier: testMessageOrder
test_case.invocations: addListener compareAndSet getData getData countDown fail format get getData sleep execute newFromType setData put assertTrue await
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMessageOrder()
focal_class.declarator: log = RosLogFactory.getLog(MessageDispatcher.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Log log = RosLogFactory.getLog(MessageDispatcher.class);
focal_class.type: Log
focal_class.var_name: log
focal_class.declarator: lazyMessages
focal_class.modifier: private final
focal_class.original_string: private final MessageBlockingQueue<LazyMessage<T>> lazyMessages;
focal_class.type: MessageBlockingQueue<LazyMessage<T>>
focal_class.var_name: lazyMessages
focal_class.declarator: messageListeners
focal_class.modifier: private final
focal_class.original_string: private final ListenerGroup<MessageListener<T>> messageListeners;
focal_class.type: ListenerGroup<MessageListener<T>>
focal_class.var_name: messageListeners
focal_class.declarator: mutex
focal_class.modifier: private final
focal_class.original_string: private final Object mutex;
focal_class.type: Object
focal_class.var_name: mutex
focal_class.declarator: latchMode
focal_class.modifier: private
focal_class.original_string: private boolean latchMode;
focal_class.type: boolean
focal_class.var_name: latchMode
focal_class.declarator: latchedMessage
focal_class.modifier: private
focal_class.original_string: private LazyMessage<T> latchedMessage;
focal_class.type: LazyMessage<T>
focal_class.var_name: latchedMessage
focal_class.file: rosjava/nrosjava/src/main/java/org/ros/internal/transport/queue/MessageDispatcher.java
focal_class.identifier: MessageDispatcher
focal_class.class_method_signature: MessageDispatcher.MessageDispatcher(MessageBlockingQueue<LazyMessage<T>> lazyMessages,
        ExecutorService executorService)
focal_class.full_signature: public  MessageDispatcher(MessageBlockingQueue<LazyMessage<T>> lazyMessages,
        ExecutorService executorService)
focal_class.identifier: MessageDispatcher
focal_class.modifiers: public
focal_class.parameters: (MessageBlockingQueue<LazyMessage<T>> lazyMessages,
        ExecutorService executorService)
focal_class.signature:  MessageDispatcher(MessageBlockingQueue<LazyMessage<T>> lazyMessages,
        ExecutorService executorService)
focal_class.class_method_signature: MessageDispatcher.addListener(MessageListener<T> messageListener, int limit)
focal_class.full_signature: public void addListener(MessageListener<T> messageListener, int limit)
focal_class.identifier: addListener
focal_class.modifiers: public
focal_class.parameters: (MessageListener<T> messageListener, int limit)
focal_class.return: void
focal_class.signature: void addListener(MessageListener<T> messageListener, int limit)
focal_class.class_method_signature: MessageDispatcher.newSignalRunnable(final LazyMessage<T> lazyMessage)
focal_class.full_signature: private SignalRunnable<MessageListener<T>> newSignalRunnable(final LazyMessage<T> lazyMessage)
focal_class.identifier: newSignalRunnable
focal_class.modifiers: private
focal_class.parameters: (final LazyMessage<T> lazyMessage)
focal_class.return: SignalRunnable<MessageListener<T>>
focal_class.signature: SignalRunnable<MessageListener<T>> newSignalRunnable(final LazyMessage<T> lazyMessage)
focal_class.class_method_signature: MessageDispatcher.setLatchMode(boolean enabled)
focal_class.full_signature: public void setLatchMode(boolean enabled)
focal_class.identifier: setLatchMode
focal_class.modifiers: public
focal_class.parameters: (boolean enabled)
focal_class.return: void
focal_class.signature: void setLatchMode(boolean enabled)
focal_class.class_method_signature: MessageDispatcher.getLatchMode()
focal_class.full_signature: public boolean getLatchMode()
focal_class.identifier: getLatchMode
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean getLatchMode()
focal_class.class_method_signature: MessageDispatcher.loop()
focal_class.full_signature: @Override public void loop()
focal_class.identifier: loop
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void loop()
focal_class.class_method_signature: MessageDispatcher.handleInterruptedException(InterruptedException e)
focal_class.full_signature: @Override protected void handleInterruptedException(InterruptedException e)
focal_class.identifier: handleInterruptedException
focal_class.modifiers: @Override protected
focal_class.parameters: (InterruptedException e)
focal_class.return: void
focal_class.signature: void handleInterruptedException(InterruptedException e)
focal_class.superclass: extends CancellableLoop
focal_method.body: public void addListener(MessageListener<T> messageListener, int limit) {
      if (log.isDebugEnabled()) {
        log.debug("Adding listener to Message Dispatcher.");
      }
      synchronized (mutex) {
        EventDispatcher<MessageListener<T>> eventDispatcher =
            messageListeners.add(messageListener, limit);
        if (latchMode && latchedMessage != null) {
          eventDispatcher.signal(newSignalRunnable(latchedMessage));
        }
      }
    }
focal_method.class_method_signature: MessageDispatcher.addListener(MessageListener<T> messageListener, int limit)
focal_method.full_signature: public void addListener(MessageListener<T> messageListener, int limit)
focal_method.identifier: addListener
focal_method.invocations: isDebugEnabled debug add signal newSignalRunnable
focal_method.modifiers: public
focal_method.parameters: (MessageListener<T> messageListener, int limit)
focal_method.return: void
focal_method.signature: void addListener(MessageListener<T> messageListener, int limit)