Class UpdateGraphWaitGuard

java.lang.Object
io.deephaven.engine.updategraph.UpdateGraphWaitGuard

public final class UpdateGraphWaitGuard extends Object
Forbids the current thread from waiting for any UpdateGraph, either to acquire one of its locks or for its update cycle to satisfy a dependency.

A thread that holds a monitor other threads may wait for, while those threads hold an update graph lock or process its updates, must not itself wait for the update graph. Such a thread may forbid waits, attempt its work, and if the work would wait, abandon it with an UpdateGraphWaitForbiddenException, release the monitor and retry the work while holding the update graph lock. A lock that is available without waiting may still be acquired, and a timed attempt to acquire one does not wait for its timeout.

  • Method Details

    • forbidWaits

      public static SafeCloseable forbidWaits()
      Forbid the current thread from waiting for any update graph until the result is closed.
      Returns:
      A SafeCloseable that restores whether the current thread was forbidden to wait
    • waitsForbidden

      public static boolean waitsForbidden()
      Returns:
      Whether the current thread is forbidden from waiting for any update graph
    • currentThreadMustNotWaitForOtherThreads

      public static boolean currentThreadMustNotWaitForOtherThreads(@NotNull @NotNull UpdateGraph updateGraph)
      Whether the current thread is forbidden to wait for any update graph, or holds a lock of, or processes updates for, updateGraph. Such a thread must not wait for work in progress on another thread, because that work may itself be waiting for the update graph.
      Parameters:
      updateGraph - The update graph whose lock or updates the current thread may hold or process
      Returns:
      Whether the current thread must not wait for work in progress on another thread