Package org.ros.concurrent
Class CancellableLoop
java.lang.Object
org.ros.concurrent.CancellableLoop
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
EventDispatcher,MessageDispatcher
An interruptable loop that can be run by an
ExecutorService.- Author:
- khughes@google.com (Keith M. Hughes)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Interrupts the loop.protected voidAnInterruptedExceptionwas thrown.booleanprotected abstract voidloop()The body of the loop.voidrun()protected voidsetup()The setup block for the loop.
-
Constructor Details
-
CancellableLoop
public CancellableLoop()
-
-
Method Details
-
run
public void run() -
setup
protected void setup()The setup block for the loop. This will be called exactly once before the first call toloop(). -
loop
The body of the loop. This will run continuously until theCancellableLoophas been interrupted externally or by callingcancel().- Throws:
InterruptedException
-
handleInterruptedException
AnInterruptedExceptionwas thrown. -
cancel
public void cancel()Interrupts the loop. -
isRunning
public boolean isRunning()- Returns:
trueif the loop is running
-