Class LockGuardedDrivenValue<T>

java.lang.Object
com.inductiveautomation.perspective.gateway.driven.LockGuardedDrivenValue<T>
Type Parameters:
T - The type of the driven value
All Implemented Interfaces:
DrivenValue<T>
Direct Known Subclasses:
ExpressionDrivenValue, LockGuardedDrivenValueCollection

public abstract class LockGuardedDrivenValue<T> extends Object implements DrivenValue<T>
A LockGuardedDrivenValue is a DrivenValue which holds a lock object and asserts that Threads which call isReady(), isDirty(), and getAndClear() hold this lock. Client code must synchronize on the lock before calling any of these methods.
See Also:
  • Field Details

    • lock

      protected final Object lock
  • Constructor Details

    • LockGuardedDrivenValue

      protected LockGuardedDrivenValue(@Nonnull Object lock)
  • Method Details

    • isReadyInternal

      protected abstract boolean isReadyInternal()
      Called after asserting that the calling thread holds the injected lock.
      See Also:
    • isReady

      public boolean isReady()
      Specified by:
      isReady in interface DrivenValue<T>
      Returns:
      true if the driven value is ready to fetch
    • isDirtyInternal

      protected abstract boolean isDirtyInternal()
      Called after asserting that the calling thread holds the injected lock.
      See Also:
    • isDirty

      public boolean isDirty()
      Specified by:
      isDirty in interface DrivenValue<T>
      Returns:
      true if the driven value has changed since the last time it was fetched
    • resolveReferencesInternal

      protected abstract Collection<PropertyReference> resolveReferencesInternal()
    • resolveReferences

      public Collection<PropertyReference> resolveReferences()
      Description copied from interface: DrivenValue
      Call before startup() to resolve and collect any references this value might depend on.
      Specified by:
      resolveReferences in interface DrivenValue<T>
    • getAndClearInternal

      @Nonnull protected abstract Optional<T> getAndClearInternal()
      Called after asserting that the calling thread holds the injected lock.
      See Also:
    • getAndClear

      @Nonnull public Optional<T> getAndClear()
      Description copied from interface: DrivenValue
      Fetch the current driven value
      Specified by:
      getAndClear in interface DrivenValue<T>
      Returns:
      An Optional containing the current driven value, if present, or an empty Optional if the driven value is null / not present.