Klasse CyclicTask

java.lang.Object
org.opentcs.util.CyclicTask
Alle implementierten Schnittstellen:
Runnable

public abstract class CyclicTask extends Object implements Runnable
A template for cyclic tasks. Subclasses only need to provide an implementation of runActualTask(), which will be called until the task is terminated by calling terminate(); after each call of runActualTask(), a configurable delay may be inserted.
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
    CyclicTask(long tSleep)
    Creates a new CyclicTask.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    boolean
    Indicates whether this task is ignoring interrupts while it's sleeping.
    boolean
    Indicates whether this task has been terminated.
    void
    run()
     
    protected abstract void
    Defines the actual work this task should do in every cycle.
    void
    setIgnoringInterrupts(boolean ignoreInterrupts)
    Sets/unsets this task's flag for ignoring interrupts during sleep phases.
    void
    Terminates this task before its next execution cycle.
    void
    Terminates this task before its next execution cycle and waits for it to finish before returning.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Konstruktordetails

    • CyclicTask

      public CyclicTask(long tSleep)
      Creates a new CyclicTask.
      Parameter:
      tSleep - The time to sleep between two executions of the actual task (in milliseconds).
  • Methodendetails

    • isTerminated

      public boolean isTerminated()
      Indicates whether this task has been terminated.
      Gibt zurück:
      true if, and only if, this task's terminated flag has been set.
    • terminate

      public void terminate()
      Terminates this task before its next execution cycle. This method merely flags the task for termination and returns immediately. If the actual task is currently being executed, its execution will not be interrupted, but it will not be run again after finishing.
    • terminateAndWait

      public void terminateAndWait()
      Terminates this task before its next execution cycle and waits for it to finish before returning. (This method waits for termination unless the calling thread is the thread that is executing this task. In that case, this method merely flags this task for termination and returns immediately.)
    • isIgnoringInterrupts

      public boolean isIgnoringInterrupts()
      Indicates whether this task is ignoring interrupts while it's sleeping.
      Gibt zurück:
      true if, and only if, this task is ignoring interrupts while it's sleeping.
    • setIgnoringInterrupts

      public void setIgnoringInterrupts(boolean ignoreInterrupts)
      Sets/unsets this task's flag for ignoring interrupts during sleep phases.
      Parameter:
      ignoreInterrupts - If true, this task will ignore interrupts during sleep phases; if false, the run() method will throw an exception when interrupted.
    • run

      public void run()
      Angegeben von:
      run in Schnittstelle Runnable
    • runActualTask

      protected abstract void runActualTask()
      Defines the actual work this task should do in every cycle.