Package org.ros.internal.transport.queue
Class MessageDispatcher<T>
java.lang.Object
org.ros.concurrent.CancellableLoop
org.ros.internal.transport.queue.MessageDispatcher<T>
- Type Parameters:
T- the message type
- All Implemented Interfaces:
Runnable
- Author:
- damonkohler@google.com (Damon Kohler)
-
Constructor Summary
ConstructorsConstructorDescriptionMessageDispatcher(CircularBlockingDeque<LazyMessage<T>> lazyMessages, ExecutorService executorService) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(org.ros.message.MessageListener<T> messageListener, int limit) Adds the specifiedMessageListenerto the internalListenerGroup.booleanprotected voidAnInterruptedExceptionwas thrown.voidloop()The body of the loop.voidRemoves all the registeredMessageListeners.booleanremoveListener(org.ros.message.MessageListener<T> messageListener) Removes the specifiedMessageListenerfrom the internalListenerGroup.voidsetLatchMode(boolean enabled) Methods inherited from class org.ros.concurrent.CancellableLoop
cancel, isRunning, run, setup
-
Constructor Details
-
MessageDispatcher
public MessageDispatcher(CircularBlockingDeque<LazyMessage<T>> lazyMessages, ExecutorService executorService)
-
-
Method Details
-
addListener
Adds the specifiedMessageListenerto the internalListenerGroup. IflatchModeistrue, thelatchedMessagewill be immediately dispatched to the specifiedMessageListener.- See Also:
-
removeListener
Removes the specifiedMessageListenerfrom the internalListenerGroup.- Parameters:
messageListener-MessageListenerto remove.- Returns:
- True if the listener was removed, false if it wasn't registered before.
- See Also:
-
removeAllListeners
public void removeAllListeners()Removes all the registeredMessageListeners.- See Also:
-
setLatchMode
public void setLatchMode(boolean enabled) - Parameters:
enabled-trueif latch mode should be enabled,falseotherwise
-
getLatchMode
public boolean getLatchMode()- Returns:
trueif latch mode is enabled,falseotherwise
-
loop
Description copied from class:CancellableLoopThe body of the loop. This will run continuously until theCancellableLoophas been interrupted externally or by callingCancellableLoop.cancel().- Specified by:
loopin classCancellableLoop- Throws:
InterruptedException
-
handleInterruptedException
Description copied from class:CancellableLoopAnInterruptedExceptionwas thrown.- Overrides:
handleInterruptedExceptionin classCancellableLoop
-