JavaScript is disabled on your browser.
Skip navigation links
  • Summary:
  • Nested |
  • Field |
  • Constr |
  • Method
  • Detail:
  • Field |
  • Constr |
  • Method
org.codefx.libfx.concurrent.when

Class ExecuteOnceWhen<T>

  • Type Parameters:
    T - the type the observed ObservableValue's wraps


    public class ExecuteOnceWhen<T>
    extends Object 
    Executes an action when an ObservableValue's value fulfills a certain condition.

    The action will not be executed before executeWhen() is called. The action is only executed once. If it was not yet executed, this can be prevented by calling cancel().

    This class guarantees that regardless of the way different threads interact with the ObservableValue the action will be executed...

    • ... if the value held when executeWhen() returns passes the condition
    • ... if a new value passes the condition (either during executeWhen() or after it returns)
    • ... at most once
    If the observable is manipulated by several threads, this class does not guarantee that the first value to pass the condition is the one handed to the action. Depending on the interaction of those threads it might be the initial value (the one tested during executeWhen()) or one of several which were set by those threads.

    Use ExecuteWhen to build an instance of this class.

    • Method Detail

      • executeWhen

        public void executeWhen()
         throws IllegalStateException 
        Executes the action (once) when the observable's value passes the condition.

        This is a one way function that must only be called once. Calling it again throws an IllegalStateException.

        Call cancel() to prevent future execution.

        Throws:
        IllegalStateException - if this method is called more than once
      • cancel

        public void cancel()
        Cancels the future execution of the action. If executeWhen() was not yet called or the action was already executed, this is a no-op.
Skip navigation links
  • Summary:
  • Nested |
  • Field |
  • Constr |
  • Method
  • Detail:
  • Field |
  • Constr |
  • Method

This documentation is licensed under CC-BY 4.0, attributed to Nicolai Parlog from CodeFX.

AltStyle によって変換されたページ (->オリジナル) /