Interface FluentSynchronizerApi.Value<T extends @Nullable Object>

All Superinterfaces:
FluentSynchronizerApi.Common
Enclosing interface:
FluentSynchronizerApi

public static interface FluentSynchronizerApi.Value<T extends @Nullable Object> extends FluentSynchronizerApi.Common
  • Method Details

    • sleepUntil

      Description copied from interface: FluentSynchronizerApi.Common
      Adds sleeping to the action chain.

      This action ensures the given condition is met before performing the next action. When this action begins, the supplier is called immediately.

      Supplier returns false:
      The chain sleeps until another chain wakes it up. The supplier is then called again and if it still returns false, the chain resumes sleeping.
      Supplier returns true:
      The chain proceeds to perform the next action.
      Specified by:
      sleepUntil in interface FluentSynchronizerApi.Common
      Parameters:
      state - the supplier that returns true if the action chain should proceed to the next action, false otherwise.
    • sleepUntil

      FluentSynchronizerApi.Value<T> sleepUntil(BooleanSupplier state, Duration checkInterval)
      Description copied from interface: FluentSynchronizerApi.Common
      Adds sleeping to the action chain.

      This action ensures the given condition is met before performing the next action. When this action begins, the supplier is called immediately.

      Supplier returns false:
      The chain sleeps until either another chain wakes it up or the checkInterval has passed.

      In both cases, the supplier is then called again and if it still returns false, the chain resumes sleeping.

      Supplier returns true:
      The chain proceeds to perform the next action.
      Specified by:
      sleepUntil in interface FluentSynchronizerApi.Common
      Parameters:
      state - the supplier that returns true if the action chain should proceed to the next action, false otherwise.
      checkInterval - how often the condition should be re-checked even if no wake call happens, or null for "never".
    • wakeOthers

      Description copied from interface: FluentSynchronizerApi.Common
      Adds an action which wakes other chains.
      Specified by:
      wakeOthers in interface FluentSynchronizerApi.Common
    • wakeOthersIf

      FluentSynchronizerApi.Value<T> wakeOthersIf(Predicate<T> predicate)
      Adds an action which conditionally wakes other chains. If the condition is false, the chain immediately proceeds to perform the next action.
      Parameters:
      predicate - a test operating on the chain result that returns true if this action chain should wake other chains, false otherwise.
      Throws:
      NullPointerException - if predicate is null
    • map

      <R extends @Nullable Object> FluentSynchronizerApi.Value<R> map(Function<T,R> function)
      Adds an action to the chain that processes or transforms the chain result.
      Parameters:
      function - the mapping function
      Throws:
      NullPointerException - if function is null
    • invoke

      @CanIgnoreReturnValue T invoke()
      Invokes the action chain in a synchronized block.

      All actions will be performed in order. This method blocks until all actions in the chain have been completed.

      While several action chains can be invoked concurrently on the same synchronizer, only one of them will perform an action at any given time. As this involves acquiring a lock shared with other action chains, care must be taken to avoid deadlocks, just as if using synchronized blocks and Object.wait() / Object.notifyAll() directly.

      Returns:
      the chain result
      Throws:
      UncheckedInterruptedException - if the thread was interrupted while waiting (i.e. performing a sleep action).
    • discardResult

      Adds an action to the chain that will discard the chain result. This allows adding subsequent run(Runnable) actions or a different get(Supplier) action.