Class RangedRunnable<T>

java.lang.Object
VASSAL.tools.concurrent.RangedRunnable<T>
Type Parameters:
T - the type of the lower and upper bounds in the range
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
Progressor

public abstract class RangedRunnable<T> extends Object implements Runnable
A Runnable which operates on a rolling range. A RangedRunnable can be updated after it has been submitted but before it has been run. This cuts down on the number of times the RangedRunnable must be submitted, and is appropriate for values where only the most recent update matters.
Since:
3.1.11
Author:
Joel Uckelman
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Pair<T,T>
     
    protected boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new RangedRunnable with the given lower bound.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    run()
    protected abstract void
    run(Pair<T,T> r)
    Processes the given range.
    final void
    setLast(T last, boolean submit)
    Sets the value of the upper end of the range.
    protected abstract void
    Hands the RangedRunnable off to be executed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • range

      protected Pair<T,T> range
    • submitted

      protected boolean submitted
  • Constructor Details

    • RangedRunnable

      public RangedRunnable(T init)
      Creates a new RangedRunnable with the given lower bound.
      Parameters:
      init - the initial lower bound
  • Method Details

    • run

      public final void run()

      Flushes the range and calls .

      Specified by:
      run in interface Runnable
    • setLast

      public final void setLast(T last, boolean submit)
      Sets the value of the upper end of the range.
      Parameters:
      last - the value to set
      submit - whether to also submit the change
    • submit

      protected abstract void submit()
      Hands the RangedRunnable off to be executed.

      This method may be executed only from .

    • run

      protected abstract void run(Pair<T,T> r)
      Processes the given range.
      Parameters:
      r - the range to process