Class CancellableLoop

java.lang.Object
org.ros.concurrent.CancellableLoop
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
EventDispatcher, MessageDispatcher

public abstract class CancellableLoop extends Object implements Runnable
An interruptable loop that can be run by an ExecutorService.
Author:
khughes@google.com (Keith M. Hughes)
  • Constructor Details

    • CancellableLoop

      public CancellableLoop()
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
    • setup

      protected void setup()
      The setup block for the loop. This will be called exactly once before the first call to loop().
    • loop

      protected abstract void loop() throws InterruptedException
      The body of the loop. This will run continuously until the CancellableLoop has been interrupted externally or by calling cancel().
      Throws:
      InterruptedException
    • handleInterruptedException

      protected void handleInterruptedException(InterruptedException e)
      An InterruptedException was thrown.
    • cancel

      public void cancel()
      Interrupts the loop.
    • isRunning

      public boolean isRunning()
      Returns:
      true if the loop is running